Skip to content
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

Fix json and yaml tags #309

Merged
merged 2 commits into from
Feb 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import (
//
// Values configured here are per-second. See zapcore.NewSampler for details.
type SamplingConfig struct {
Initial int `json:"initial",yaml:"initial"`
Thereafter int `json:"therafter",yaml:"thereafter"`
Initial int `json:"initial" yaml:"initial"`
Thereafter int `json:"therafter" yaml:"thereafter"`
}

// Config offers a declarative way to construct a logger.
Expand All @@ -48,33 +48,33 @@ type Config struct {
// level, so calling Config.Level.SetLevel will atomically change the log
// level of all loggers descended from this config. The zero value is
// InfoLevel.
Level AtomicLevel `json:"level",yaml:"level"`
Level AtomicLevel `json:"level" yaml:"level"`
// Development puts the logger in development mode, which changes the
// behavior of DPanicLevel and takes stacktraces more liberally.
Development bool `json:"development",yaml:"development"`
Development bool `json:"development" yaml:"development"`
// DisableCaller stops annotating logs with the calling function's file
// name and line number. By default, all logs are annotated.
DisableCaller bool `json:"disableCaller",yaml:"disableCaller"`
DisableCaller bool `json:"disableCaller" yaml:"disableCaller"`
// DisableStacktrace completely disables automatic stacktrace capturing. By
// default, stacktraces are captured for WarnLevel and above logs in
// development and ErrorLevel and above in production.
DisableStacktrace bool `json:"disableStacktrace",yaml:"disableStacktrace"`
DisableStacktrace bool `json:"disableStacktrace" yaml:"disableStacktrace"`
// Sampling sets a sampling policy. A nil SamplingConfig disables sampling.
Sampling *SamplingConfig `json:"sampling",yaml:"sampling"`
Sampling *SamplingConfig `json:"sampling" yaml:"sampling"`
// Encoding sets the logger's encoding. Valid values are "json" and
// "console".
Encoding string `json:"encoding",yaml:"encoding"`
Encoding string `json:"encoding" yaml:"encoding"`
// EncoderConfig sets options for the chosen encoder. See
// zapcore.EncoderConfig for details.
EncoderConfig zapcore.EncoderConfig `json:"encoderConfig",yaml:"encoderConfig"`
EncoderConfig zapcore.EncoderConfig `json:"encoderConfig" yaml:"encoderConfig"`
// OutputPaths is a list of paths to write logging output to. See Open for
// details.
OutputPaths []string `json:"outputPaths",yaml:"outputPaths"`
OutputPaths []string `json:"outputPaths" yaml:"outputPaths"`
// ErrorOutputPaths is a list of paths to write internal logger errors to.
// The default is standard error.
ErrorOutputPaths []string `json:"errorOutputPaths",yaml:"errorOutputPaths"`
ErrorOutputPaths []string `json:"errorOutputPaths" yaml:"errorOutputPaths"`
// InitialFields is a collection of fields to add to the root logger.
InitialFields map[string]interface{} `json:"initialFields",yaml:"initialFields"`
InitialFields map[string]interface{} `json:"initialFields" yaml:"initialFields"`
}

// NewProductionConfig is the recommended production configuration. Logging is
Expand Down
18 changes: 9 additions & 9 deletions zapcore/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,18 @@ func (e *DurationEncoder) UnmarshalText(text []byte) error {
// zapcore.
type EncoderConfig struct {
// Set the keys used for each log entry.
MessageKey string `json:"messageKey",yaml:"messageKey"`
LevelKey string `json:"levelKey",yaml:"levelKey"`
TimeKey string `json:"timeKey",yaml:"timeKey"`
NameKey string `json:"nameKey",yaml:"nameKey"`
CallerKey string `json:"callerKey",yaml:"callerKey"`
StacktraceKey string `json:"stacktraceKey",yaml:"stacktraceKey"`
MessageKey string `json:"messageKey" yaml:"messageKey"`
LevelKey string `json:"levelKey" yaml:"levelKey"`
TimeKey string `json:"timeKey" yaml:"timeKey"`
NameKey string `json:"nameKey" yaml:"nameKey"`
CallerKey string `json:"callerKey" yaml:"callerKey"`
StacktraceKey string `json:"stacktraceKey" yaml:"stacktraceKey"`
// Configure the primitive representations of common complex types. For
// example, some users may want all time.Times serialized as floating-point
// seconds since epoch, while others may prefer ISO8601 strings.
EncodeLevel LevelEncoder `json:"levelEncoder",yaml:"levelEncoder"`
EncodeTime TimeEncoder `json:"timeEncoder",yaml:"timeEncoder"`
EncodeDuration DurationEncoder `json:"durationEncoder",yaml:"durationEncoder"`
EncodeLevel LevelEncoder `json:"levelEncoder" yaml:"levelEncoder"`
EncodeTime TimeEncoder `json:"timeEncoder" yaml:"timeEncoder"`
EncodeDuration DurationEncoder `json:"durationEncoder" yaml:"durationEncoder"`
}

// ObjectEncoder is a strongly-typed, encoding-agnostic interface for adding a
Expand Down