Documentation ¶
Index ¶
- func NewCore(cfg ecszap.EncoderConfig, ws zapcore.WriteSyncer, enab zapcore.LevelEnabler) zapcore.Core
- func NewError(err error) zapcore.ObjectMarshaler
- func WrapCore(c zapcore.Core) zapcore.Core
- func WrapCoreOption() zap.Option
- type Config
- type ILogger
- type Logger
- func (l Logger) Debug(msg string, fields ...zap.Field)
- func (l Logger) Error(msg string, err error, fields ...zap.Field)
- func (l Logger) Fatal(msg string, err error, fields ...zap.Field)
- func (l Logger) Info(msg string, fields ...zap.Field)
- func (l Logger) Log(level zapcore.Level, msg string, fields ...zap.Field)
- func (l Logger) Println(args ...interface{})
- type ServiceConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCore ¶
func NewCore(cfg ecszap.EncoderConfig, ws zapcore.WriteSyncer, enab zapcore.LevelEnabler) zapcore.Core
NewCore creates a zapcore.Core that uses an ECS conformant JSON encoder. This is the safest way to create an ECS compatible core.
func NewError ¶
func NewError(err error) zapcore.ObjectMarshaler
func WrapCore ¶
WrapCore wraps a core with ECS core functionality and returns a zapcore.Core. For ECS compatibility, ensure that the wrapped zapcore.Core uses an encoder that is created from an ECS compatible configuration. For further details check out ecszap.EncoderConfig or ecszap.ECSCompatibleEncoderConfig.
func WrapCoreOption ¶
WrapCoreOption returns a zap.Option, wrapping the underlying zapcore.Core.
Types ¶
type Config ¶
type Config struct { Service ServiceConfig Console bool Path string Level zapcore.Level }
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger logs to a file following ElasticSearch ECS standard. It is compatible with pkg/errors and eris error libraries. It can also print to console depending on the values passed to Init
func New ¶
New returns a configured Logger.
serviceId must distinctly identify the service that is using the logger. If the service runs in multiple nodes, the serviceId should be the same for all. For example an indexer for SEC filings running on 10 nodes, can have "indexer_sec" as id across all instances.
serviceName is just a readable name for the service that will be added to logs.
Logs to logPath. If logPath is empty or logToConsole is true, then it logs to console.