Documentation
¶
Index ¶
- Variables
- func ConfigureDefault(configFile string, w io.Writer)
- func Debug(msg interface{}, keyvals ...interface{})
- func DebugEnvOverride() bool
- func Error(msg interface{}, keyvals ...interface{})
- func Info(msg interface{}, keyvals ...interface{})
- func SetDefault(logger AppLogger)
- func Sync() error
- func Warn(msg interface{}, keyvals ...interface{})
- type AppLogger
- type ConsoleLogConfig
- type FileLogConfig
- type FxLogger
- type LogConfig
- type LogOptionsConfig
- type TerraformLogConfig
- type ZapLogger
- func (l *ZapLogger) Debug(msg interface{}, keyvals ...interface{})
- func (l *ZapLogger) Error(msg interface{}, keyvals ...interface{})
- func (l *ZapLogger) Info(msg interface{}, keyvals ...interface{})
- func (l *ZapLogger) LogEvent(event fxevent.Event)
- func (l *ZapLogger) Sync() error
- func (l *ZapLogger) Warn(msg interface{}, keyvals ...interface{})
Constants ¶
This section is empty.
Variables ¶
var DefaultLogConfig = LogConfig{ Log: LogOptionsConfig{ Console: ConsoleLogConfig{ Level: "error", }, File: FileLogConfig{ Enabled: false, Path: "log/$name.$date.log", Level: "info", }, Terraform: TerraformLogConfig{ Enabled: false, Path: "log/$name.$date.tf.log", Level: "trace", }, }, }
DefaultLogConfig provides the default logging configuration.
Functions ¶
func ConfigureDefault ¶
ConfigureDefault configures the default logger using the provided configuration file and writer. If an error occurs during configuration, it falls back to the default logger.
func Debug ¶
func Debug(msg interface{}, keyvals ...interface{})
Debug logs a debug message using the default logger.
func DebugEnvOverride ¶
func DebugEnvOverride() bool
DebugEnvOverride checks if the DEBUG environment variable is set to "true" or "1". If set, all loggers will be overridden to debug level regardless of the configured thresholds.
func Error ¶
func Error(msg interface{}, keyvals ...interface{})
Error logs an error message using the default logger.
func Info ¶
func Info(msg interface{}, keyvals ...interface{})
Info logs an informational message using the default logger.
func SetDefault ¶
func SetDefault(logger AppLogger)
SetDefault sets the provided logger as the default global logger.
Types ¶
type AppLogger ¶
type AppLogger interface {
Sync() error
Debug(msg interface{}, keyvals ...interface{})
Info(msg interface{}, keyvals ...interface{})
Warn(msg interface{}, keyvals ...interface{})
Error(msg interface{}, keyvals ...interface{})
LogEvent(event fxevent.Event)
}
AppLogger defines the interface for application loggers.
type ConsoleLogConfig ¶
type ConsoleLogConfig struct {
Level string `koanf:"level"`
}
ConsoleLogConfig represents the configuration for console logging.
type FileLogConfig ¶
type FileLogConfig struct {
Enabled bool `koanf:"enabled"`
Path string `koanf:"path"`
Level string `koanf:"level"`
}
FileLogConfig represents the configuration for file-based logging.
type FxLogger ¶
type FxLogger struct {
// contains filtered or unexported fields
}
FxLogger is a logger implementation for Uber FX that uses a fallback logger until the default logger is configured.
func NewFxLogger ¶
func NewFxLogger() *FxLogger
NewFxLogger creates a new FxLogger instance. It uses the system's default logger if debugging is enabled, or a no-op logger otherwise. This suppresses initial DI container logs until the logger is fully configured.
type LogConfig ¶
type LogConfig struct {
Name string `koanf:"name"`
Log LogOptionsConfig `koanf:"log"`
}
LogConfig represents the configuration for logging, including log name and options.
func NewLogConfig ¶
NewLogConfig loads the logging configuration from the specified file path. If the path is empty or an error occurs, it returns the default configuration.
type LogOptionsConfig ¶
type LogOptionsConfig struct {
Console ConsoleLogConfig `koanf:"console"`
File FileLogConfig `koanf:"file"`
Terraform TerraformLogConfig `koanf:"terraform"`
}
LogOptionsConfig contains configuration options for different logging outputs.
type TerraformLogConfig ¶
type TerraformLogConfig struct {
Enabled bool `koanf:"enabled"`
Path string `koanf:"path"`
Level string `koanf:"level"`
}
TerraformLogConfig represents the configuration for Terraform-specific logging.
type ZapLogger ¶
type ZapLogger struct {
// contains filtered or unexported fields
}
ZapLogger is a logger implementation using Uber's Zap library.
func (*ZapLogger) Debug ¶
func (l *ZapLogger) Debug(msg interface{}, keyvals ...interface{})
Debug prints a debug message with optional key-value pairs.
func (*ZapLogger) Error ¶
func (l *ZapLogger) Error(msg interface{}, keyvals ...interface{})
Error prints an error message with optional key-value pairs.
func (*ZapLogger) Info ¶
func (l *ZapLogger) Info(msg interface{}, keyvals ...interface{})
Info prints an informational message with optional key-value pairs.