Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(logging): add lualogging compatible logging #149

Merged
merged 3 commits into from
Sep 30, 2024

Conversation

Tieske
Copy link
Contributor

@Tieske Tieske commented Sep 12, 2024

This is a minimum implementation. Should it add more debug level logging in places?

@Tieske Tieske marked this pull request as ready for review September 12, 2024 20:58
@Tieske
Copy link
Contributor Author

Tieske commented Sep 13, 2024

example output:

Tieskes-MBP:pegasus.lua thijs$ lua example/copas.lua
Fri Sep 13 09:29:42 2024 DEBUG Handler created, without location
Fri Sep 13 09:29:42 2024 INFO Pegasus is up on http://localhost:9090
Fri Sep 13 09:29:42 2024 DEBUG Handler created, without location
Fri Sep 13 09:29:42 2024 INFO Pegasus is up on https://localhost:9091
Fri Sep 13 09:30:01 2024 INFO Request for: GET /index.html
Fri Sep 13 09:30:01 2024 INFO Request for: GET /style.css
Fri Sep 13 09:30:01 2024 INFO Request for: GET /1.jpg
Fri Sep 13 09:30:17 2024 INFO Request for: POST /index.html
Fri Sep 13 09:30:25 2024 INFO Request for: GET /index.html
Fri Sep 13 09:30:34 2024 INFO Request for: GET /api/1v0/people/John
Fri Sep 13 09:30:34 2024 DEBUG served John's data
Fri Sep 13 09:30:43 2024 INFO Request for: GET /api/1v0/people/Mary
Fri Sep 13 09:30:43 2024 ERROR 'Mary' is an unknown person
Fri Sep 13 09:33:35 2024 INFO Request for: GET /downloads/1.jpg
Fri Sep 13 09:33:58 2024 INFO Request for: POST /index.html
Fri Sep 13 09:34:07 2024 INFO Request for: GET /index.html

@EvandroLG EvandroLG self-requested a review September 21, 2024 20:57
@EvandroLG
Copy link
Owner

Super nice PR, @Tieske :)
I just didn't get why you're passing the log through the Handler. Wouldn't it be simpler to directly call the log module in the relevant modules, or is there something I'm overlooking?

@Tieske
Copy link
Contributor Author

Tieske commented Sep 23, 2024

to be able to set it per handler. Otherwise it would become a global. In case you are serving multiple server sockets and would like separate logging.

for example create 2 loggers with the following log patterns:

    "%date %level [server1] %message (%source)"

    "%date %level [server2] %message (%source)"

And then pass those to the handlers of the 2 server sockets we're handling (note that %date, %level, %message and %source are placeholders that will be replaced by the actual log data). This would cleanly identify the source of the loglines, even if sent to the same log destination)

@EvandroLG EvandroLG merged commit c0e9b4d into EvandroLG:master Sep 30, 2024
6 checks passed
@Tieske Tieske deleted the logging branch October 1, 2024 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants