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

Add log output config option #172

Merged
merged 3 commits into from
Dec 27, 2023
Merged

Conversation

jahands
Copy link
Contributor

@jahands jahands commented Dec 15, 2023

I'm hosting Opengist in Docker, with stdout logs being sent to Axiom, and didn't want the log file taking up disk space.

This adds a new config option: log-output (OG_LOG_OUTPUT) that takes a comma-separated list of outputs (stdout and file are supported.)

Testing:

  • Built docker image and deployed
  • Tested with several variations and confirmed it worked as expected:
    • stdout
    • stdout,file
    • file
    • stdout,file,foo
    • foo
  • Also tested specifying no outputs and it correctly defaulted to stdout

for _, logOutputType := range logOutputTypes {
logOutputType = strings.TrimSpace(logOutputType)
if !utils.SliceContains([]string{"stdout", "file"}, logOutputType) {
defer func() { log.Warn().Msg("Invalid log output type: " + logOutputType) }()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used defer for these logs so that they get logged after the logger is initialized

@jahands jahands changed the base branch from master to dev-1.6 December 15, 2023 21:56
@@ -5,6 +5,9 @@
# Set the log level to one of the following: trace, debug, info, warn, error, fatal, panic. Default: warn
log-level: warn

# Set the log output to one or more of the following: `stdout`, `file`. Default: stdout,file
log-output: stdout,file
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed this, thanks

@thomiceli thomiceli merged commit 76ff41e into thomiceli:dev-1.6 Dec 27, 2023
8 checks passed
@thomiceli
Copy link
Owner

Thanks for the feature!

thomiceli added a commit that referenced this pull request Jan 4, 2024
Co-authored-by: Thomas Miceli <27960254+thomiceli@users.noreply.github.com>
jiriks74 pushed a commit to jiriks74/opengist that referenced this pull request Apr 28, 2024
Co-authored-by: Thomas Miceli <27960254+thomiceli@users.noreply.github.com>
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