feat: add precise diagnostics and optional client copy logging controls
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
||||
// standard stream. File takes precedence over Output and appends to the named
|
||||
// file.
|
||||
type Config struct {
|
||||
TimeZone string `json:"timeZone"` // Empty retains existing timestamp behavior.
|
||||
Level string `json:"level"`
|
||||
Format string `json:"format"`
|
||||
Output string `json:"output"`
|
||||
@@ -73,7 +74,8 @@ func init() {
|
||||
// call Close when the process is shutting down.
|
||||
func New(cfg Config) (*Logger, error) {
|
||||
cfg = normalizeConfig(cfg)
|
||||
if err := cfg.Validate(); err != nil {
|
||||
location, err := cfg.validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
level, err := parseLevel(cfg.Level)
|
||||
@@ -95,6 +97,9 @@ func New(cfg Config) (*Logger, error) {
|
||||
} else {
|
||||
handler = slog.NewJSONHandler(writer, opts)
|
||||
}
|
||||
if location != nil {
|
||||
handler = zoneHandler{Handler: handler, location: location}
|
||||
}
|
||||
logger := slog.New(handler)
|
||||
if cfg.Service != "" {
|
||||
logger = logger.With("service", cfg.Service)
|
||||
|
||||
Reference in New Issue
Block a user