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: Add logger #179

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

feat: Add logger #179

wants to merge 3 commits into from

Conversation

alcb1310
Copy link
Contributor

@alcb1310 alcb1310 commented Sep 22, 2024

This PR will close issue #140

Adds structured logger to the application

Usage

Define your logs by priority: Debug, Info, Warn and Error by adding the following to the code

import log/slog

slog.Debug("Debug message")
slog.Info("Information message")
slog.Warn("Warning message")
slog.Error("Error message")

To set the debug level when running:

ENV=debug sesh

Just need to change the debug text for info or error. The default log level is warn.

By default all logs will go to a file, which will be in the `<user home
directory>/.config/sesh` and the file will be named
`<year-month-day>.log`

If running in other than the default mode, logs will be also be
displayed in screen
@alcb1310 alcb1310 mentioned this pull request Sep 22, 2024
@alcb1310
Copy link
Contributor Author

Made some decisions to implement this, it will be good to have your input about those:

  • Log file location: I decided to use the following ~/.config/sesh/<date>.log
  • Log file name: I decided to use the date in the format YYYY-mm-dd as the log file name
  • Default log level: If no log level is defined, I set being the warn level as the default one
  • When using the default log level, I decided not to show the user the log information and only save the log to the specified file

@alcb1310 alcb1310 changed the title Logger feat: Add logger Sep 22, 2024
@joshmedeski
Copy link
Owner

I'll review this and plan on merging it later this week, thanks!

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