-
Notifications
You must be signed in to change notification settings - Fork 39
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
Adding support for saving the logs in a specified file #366
Conversation
7190bb8
to
46f0bcd
Compare
Signed-off-by: Jay Sheth <[email protected]>
Signed-off-by: Jay Sheth <[email protected]>
Signed-off-by: Jay Sheth <[email protected]>
…xing docs Signed-off-by: Jay Sheth <[email protected]>
46f0bcd
to
6eb8c60
Compare
Signed-off-by: Jay Sheth <[email protected]>
config/config.go
Outdated
@@ -105,6 +108,8 @@ func ReadConfig(configPath string) (*Config, error) { | |||
BPFLogDir: LoadOptionalConfigString(confReader, "l3afd", "bpf-log-dir", ""), | |||
MinKernelMajorVer: LoadOptionalConfigInt(confReader, "l3afd", "kernel-major-version", 5), | |||
MinKernelMinorVer: LoadOptionalConfigInt(confReader, "l3afd", "kernel-minor-version", 15), | |||
FileLogging: LoadOptionalConfigBool(confReader, "l3afd", "file-logging", false), | |||
FileLogLocation: LoadOptionalConfigString(confReader, "l3afd", "file-log-location", "l3afd.log"), |
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.
Can we have one option that allows the program to write to a specific file path, "log-file-path: /var/log/l3afd.log", if it is provided? Otherwise, if no file path is specified, the program should follow the default behavior of not writing to a log 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.
Fixed
Signed-off-by: Jay Sheth <[email protected]>
@@ -58,6 +59,20 @@ func setupLogging() { | |||
log.Debug().Msgf("Log level set to %q", logLevel) | |||
} | |||
|
|||
func saveLogsToFile(conf *config.Config) { |
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.
Can input only FileLogLocation instead of entire conf here.
config/l3afd.cfg
Outdated
@@ -14,7 +14,7 @@ swagger-api-enabled: false | |||
environment: PROD | |||
# BpfMapDefaultPath is base path for storing maps | |||
BpfMapDefaultPath: /sys/fs/bpf | |||
|
|||
file-log-location: l3afd.log |
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.
what is the absolute file location path here?
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.
Fixed
Signed-off-by: Jay Sheth <[email protected]>
Signed-off-by: Jay Sheth <[email protected]>
Signed-off-by: Jay Sheth <[email protected]>
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.
LGTM, just one question inline
main.go
Outdated
|
||
logFileWithRotation := &lumberjack.Logger{ | ||
Filename: confFileLogLocation, | ||
MaxSize: 100, // Max size in megabytes |
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.
I like log rotation, but are these parameters something that should be configurable by the user?
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.
Fixed. Added config parameters, that users can utilize to provide log rotation handles
Signed-off-by: Jay Sheth <[email protected]>
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.
LGTM, Thanks!
Currently, L3AFD logs are only displayed on STDOUT. However, in some usecases, the logging and metrics framework might require the logs to be saved to persistent storage or discs. This PR add the functionality of allowing user to save logs to the file as well. The file includes log-rotation by default