Skip to content

Fallback to console log when can't write log file - #689

Closed
braginini wants to merge 2 commits into
mainfrom
feature/fix_log_setup
Closed

Fallback to console log when can't write log file#689
braginini wants to merge 2 commits into
mainfrom
feature/fix_log_setup

Conversation

@braginini

Copy link
Copy Markdown
Collaborator

Describe your changes

Skip writing log file when permissions don't allow write operations.
Fallback to CONSOLE log output.

Issue ticket number and link

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

Comment thread util/log.go
}

logPath = "/tmp/netbird/netbird/netbird.log"
if logPath != "" && logPath != "console" {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I recommend to move this scope into a new function. And always good idea to avoid the deep if-else statements.
I. e.

if logPath == "" {
  return
}
if logPath == "console" {
  return
}

if !canWrite {
 return
}
...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I point to the 25. line. Sry

@braginini

Copy link
Copy Markdown
Collaborator Author

we will close this PR. @mlsmaycon found a better solution
#692

@braginini braginini closed this Feb 16, 2023
@mlsmaycon
mlsmaycon deleted the feature/fix_log_setup branch February 17, 2023 13:11
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