dunglas / frankenphp

🧟 The modern PHP app server
https://frankenphp.dev
MIT License
6.84k stars 234 forks source link

Option to minimize info / lines in log entries #560

Open binaryfire opened 8 months ago

binaryfire commented 8 months ago

Describe you feature request

Would it be possible to add a flag to reduce the amount of info in each log entry? We've switched from using the binary with Octane to the Docker image for local development. One thing I really miss is Octane's minimal log output. The container's log entries are verbose and it makes it hard for devs to see what's going on.

dunglas commented 8 months ago

Isn't increasing the default log level enough?

binaryfire commented 8 months ago

The problem isn't the amount of entries, it's the amount of data in each entry. DEBUG is good for local development, and Octane strips out the non-essential info from each entry it receives from the binary before sending it to stdout. Which makes it a lot more readable.

The "raw" entries from the container aren't very readable, even when the format is set to console.

dunglas commented 8 months ago

Maybe could we add a "fancy" mode directly in Caddy?

binaryfire commented 8 months ago

Yeah that would be perfect.

withinboredom commented 8 months ago

Haha, I was just cussing out the logs not 10 minutes ago. They're terrible for debugging/reading as a human. Especially when it pushes an entire stack-trace into a single line. It makes me want to tear my eyes out just so I never have to see it again.

This idea is 💯

mholt commented 8 months ago

(Chiming in from the Caddy team)

We're open to improving logs -- it was first and foremost important to ensure the logs were capable of providing as much information and context as possible, and are efficient as possible. The current logs require zero allocations and are structured so they can be arbitrarily expanded with more information. The format ("encoding") of the logs can also be customized and the data can be filtered. There are already Caddy modules that can alter these things. Additionally, any unwanted log lines can simply be ignored or discarded.

What kinds of solutions would you recommend? The problem is finding a solution that works for everyone.

Octane strips out the non-essential info from each entry

What constitutes "non-essential"?

Perhaps a "before-after" comparison could be helpful. What's your dream log output?

withinboredom commented 8 months ago

@mholt I'm not sure this is a caddy-specific issue, more of caddy output not being good for unstructured logging from PHP. If PHP could output structured logs, then merge into caddy's structured logs ... it would be infinitely better. The problem is that PHP outputs unstructured logs, which just get json encoded.

mholt commented 8 months ago

The encoder can be customized in a Caddy config. So it doesn't have to be JSON. Would that help?