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): reopen on sighup #7140
base: master
Are you sure you want to change the base?
Conversation
ArtifactsThese changes are published for testing on Buildkite, DockerHub and GitHub Container Registry. Docker Container
|
WalkthroughThe update focuses on enhancing the logging mechanism for a service by introducing a new Changes
Assessment against linked issues
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (6)
Files skipped from review as they are similar to previous changes (5)
Additional comments not posted (3)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
6bf365e
to
92b5857
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7140 +/- ##
==========================================
- Coverage 73.68% 73.57% -0.12%
==========================================
Files 346 347 +1
Lines 29973 30052 +79
Branches 839 839
==========================================
+ Hits 22087 22110 +23
- Misses 7015 7070 +55
- Partials 871 872 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
92b5857
to
a77b0fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
@@ -59,9 +59,9 @@ func ConfigureLogger(config schema.Log, log bool) (err error) { | |||
|
|||
switch { | |||
case config.FilePath != "": | |||
var file *os.File | |||
file = NewFile(config.FilePath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Declare the file
variable before using it to avoid scope issues.
+ var file *FileHandler
file = NewFile(config.FilePath)
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
file = NewFile(config.FilePath) | |
var file *FileHandler | |
file = NewFile(config.FilePath) |
// Reopen handles safely reopening the log file. | ||
func Reopen() (err error) { | ||
if file == nil { | ||
return fmt.Errorf("error reopening log file: file is not configured") | ||
} | ||
|
||
return file.Open() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider encapsulating the file
variable within a struct to manage its scope and lifecycle more effectively.
type Logger struct {
file *FileHandler
}
func (l *Logger) Reopen() error {
if l.file == nil {
return fmt.Errorf("error reopening log file: file is not configured")
}
return l.file.Open()
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
// Reopen handles safely reopening the log file. | |
func Reopen() (err error) { | |
if file == nil { | |
return fmt.Errorf("error reopening log file: file is not configured") | |
} | |
return file.Open() | |
} | |
type Logger struct { | |
file *FileHandler | |
} | |
func (l *Logger) Reopen() error { | |
if l.file == nil { | |
return fmt.Errorf("error reopening log file: file is not configured") | |
} | |
return l.file.Open() | |
} |
Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
a77b0fa
to
47d049a
Compare
This implements a method to send Authelia a SIGHUP signal to indicate it should reload the configuration file. This can be used in two ways. If using an external logrotate service you can tell Authelia to reopen the file and create it if it doesn't exist. Secondly if you use the existing time date replacements this will create a brand new log file with the current time.
Closes #4964
Summary by CodeRabbit