Skip to content

Commit

Permalink
build: add yaml tags to embedded LogConfig structs
Browse files Browse the repository at this point in the history
For any embedded struct, the `yaml:",inline"` tag is required.
  • Loading branch information
ellemouton committed Mar 4, 2025
1 parent f744a54 commit 8ab05f0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions build/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const (
type LogConfig struct {
Console *consoleLoggerCfg `group:"console" namespace:"console" description:"The logger writing to stdout and stderr."`
File *FileLoggerConfig `group:"file" namespace:"file" description:"The logger writing to LND's standard log file."`
NoCommitHash bool `long:"no-commit-hash" description:"If set, the commit-hash of the current build will not be included in log lines by default."`
NoTimestamps bool `long:"no-timestamps" description:"Omit timestamps from log lines."`
}

// Validate validates the LogConfig struct values.
Expand All @@ -45,7 +45,7 @@ func (c *LogConfig) Validate() error {
//nolint:ll
type LoggerConfig struct {
Disable bool `long:"disable" description:"Disable this logger."`
NoTimestamps bool `long:"no-timestamps" description:"Omit timestamps from log lines."`
NoTimestamps bool `long:"no-timestamps"description:"Omit timestamps from log lines."`
CallSite string `long:"call-site" description:"Include the call-site of each log line." choice:"off" choice:"short" choice:"long"`
}

Expand All @@ -57,7 +57,7 @@ func DefaultLogConfig() *LogConfig {
Compressor: defaultLogCompressor,
MaxLogFiles: DefaultMaxLogFiles,
MaxLogFileSize: DefaultMaxLogFileSize,
LoggerConfig: LoggerConfig{
LoggerConfig: &LoggerConfig{
CallSite: callSiteOff,
},
},
Expand Down Expand Up @@ -92,7 +92,7 @@ func (cfg *LoggerConfig) HandlerOptions() []btclog.HandlerOption {
//
//nolint:ll
type FileLoggerConfig struct {
LoggerConfig
*LoggerConfig `yaml:",inline"`
Compressor string `long:"compressor" description:"Compression algorithm to use when rotating logs." choice:"gzip" choice:"zstd"`
MaxLogFiles int `long:"max-files" description:"Maximum logfiles to keep (0 for no rotation)"`
MaxLogFileSize int `long:"max-file-size" description:"Maximum logfile size in MB"`
Expand Down
6 changes: 3 additions & 3 deletions build/config_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ const (
//
//nolint:ll
type consoleLoggerCfg struct {
LoggerConfig
Style bool `long:"style" description:"If set, the output will be styled with color and fonts"`
*LoggerConfig `yaml:",inline"`
Style bool `long:"style" description:"If set, the output will be styled with color and fonts"`
}

// defaultConsoleLoggerCfg returns the default consoleLoggerCfg for the dev
// console logger.
func defaultConsoleLoggerCfg() *consoleLoggerCfg {
return &consoleLoggerCfg{
LoggerConfig: LoggerConfig{
LoggerConfig: &LoggerConfig{
CallSite: callSiteShort,
},
}
Expand Down
4 changes: 2 additions & 2 deletions build/config_prod.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ package build
//
//nolint:ll
type consoleLoggerCfg struct {
LoggerConfig
*LoggerConfig `yaml:",inline"`
}

// defaultConsoleLoggerCfg returns the default consoleLoggerCfg for the prod
// console logger.
func defaultConsoleLoggerCfg() *consoleLoggerCfg {
return &consoleLoggerCfg{
LoggerConfig: LoggerConfig{
LoggerConfig: &LoggerConfig{
CallSite: callSiteOff,
},
}
Expand Down

0 comments on commit 8ab05f0

Please sign in to comment.