GithubHelp home page GithubHelp logo

Better log output about laravel-http-logger HOT 11 CLOSED

spatie avatar spatie commented on August 29, 2024
Better log output

from laravel-http-logger.

Comments (11)

freekmurze avatar freekmurze commented on August 29, 2024 1

I like a JSON format, because you could copy/paste it right into a REST client.

I very much like this idea.

from laravel-http-logger.

sebastiandedeyne avatar sebastiandedeyne commented on August 29, 2024 1

Confused, isn't that what it looks like now? 🤔

https://github.com/spatie/laravel-http-logger/blob/48f75eeba9cbcc87471f9c880e5a3288d29d504b/src/DefaultLogProfile.php

from laravel-http-logger.

sebastiandedeyne avatar sebastiandedeyne commented on August 29, 2024

We've done print_r in the past, there's probably a better solution though.

from laravel-http-logger.

brendt avatar brendt commented on August 29, 2024

I like a JSON format, because you could copy/paste it right into a REST client.

Maybe the headers should also be logged?

from laravel-http-logger.

brendt avatar brendt commented on August 29, 2024

As it seems, all newlines are stripped when using the Log. This results in difficult to read output.

from laravel-http-logger.

brendt avatar brendt commented on August 29, 2024

Turns out Monolog can have different formatters, and you can make your own. Laravel also has its wrapper around this: Illuminate\Log\Writer in which formatter can be configured.

I didn't go as far as making our own formatter, but it seems like a possibility, enabling new lines. I don't think it's worth the time now, but might be a nice feature for the future.

from laravel-http-logger.

brendt avatar brendt commented on August 29, 2024

@freekmurze But the question about formatting in the log output itself still stands. What's your opinion? To format the JSON in a pretty way, we'll have to create a custom formatter.

Functionally the unformatted JSON output will of course work just as fine; so pretty format might not be that important.

from laravel-http-logger.

pmatseykanets avatar pmatseykanets commented on August 29, 2024

It would be nice to separate concerns of

  • figuring out what requests to log or not shouldLogRequest()
  • and format in which the log is being written logRequest()

This way regardless of logger/formatter requests that shouldn't be logged won't be.

from laravel-http-logger.

freekmurze avatar freekmurze commented on August 29, 2024

That's a pretty good idea, let's do that @brendt .

from laravel-http-logger.

brendt avatar brendt commented on August 29, 2024

I share @sebastiandedeyne's confusion, or were you maybe @pmatseykanets was referring to further split it in separate classes?

from laravel-http-logger.

freekmurze avatar freekmurze commented on August 29, 2024

Separating concerns will be handled in #7

Current log output is good enough for a v1.0.0

from laravel-http-logger.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.