{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v1.4.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package flogging\n\n## Constants\n\n```go\nconst (\n\tCONSOLE = iota\n\tJSON\n\tLOGFMT\n)\n```\n\n```go\nconst (\n\t// DisabledLevel represents a disabled log level. Logs at this level should\n\t// never be emitted.\n\tDisabledLevel = zapcore.Level(math.MinInt8)\n\n\t// PayloadLevel is used to log the extremely detailed message level debug\n\t// information.\n\tPayloadLevel = zapcore.Level(zapcore.DebugLevel - 1)\n)\n```\n\n## Functions\n\n```go\nfunc ActivateSpec(spec string)\n```\nActivateSpec is used to activate a logging specification.\n\n```go\nfunc DefaultLevel() string\n```\nDefaultLevel returns the fallback value for loggers to use if parsing fails.\n\n```go\nfunc GetLoggerLevel(loggerName string) string\n```\nGetLoggerLevel gets the current logging level for the logger with the provided name.\n\n```go\nfunc Init(config Config)\n```\nInit initializes logging with the provided config.\n\n```go\nfunc InitBackend(formatter logging.Formatter, output io.Writer)\n```\nInitBackend sets up the logging backend based on the provided logging formatter and I/O writer.\n\n```go\nfunc InitFromSpec(spec string) string\n```\nInitFromSpec initializes the logging based on the supplied spec. It is exposed externally so that consumers of the flogging package may parse their own logging specification. The logging specification has the following form:\n\n\t[\u003clogger\u003e[,\u003clogger\u003e...]=]\u003clevel\u003e[:[\u003clogger\u003e[,\u003clogger\u003e...]=]\u003clogger\u003e...]\n\n```go\nfunc IsValidLevel(level string) bool\n```\n\n```go\nfunc NameToLevel(level string) zapcore.Level\n```\nNameToLevel converts a level name to a zapcore.Level.  If the level name is unknown, zapcore.InfoLevel is returned.\n\n```go\nfunc NewGRPCLogger(l *zap.Logger) *zapgrpc.Logger\n```\nNewGRPCLogger creates a grpc.Logger that delegates to a zap.Logger.\n\n```go\nfunc NewZapLogger(core zapcore.Core, options ...zap.Option) *zap.Logger\n```\nNewZapLogger creates a zap logger around a new zap.Core. The core will use the provided encoder and sinks and a level enabler that is associated with the provided logger name. The logger that is returned will be named the same as the logger.\n\n```go\nfunc Reset()\n```\nReset sets logging to the defaults defined in this package.\n\nUsed in tests and in the package init\n\n```go\nfunc SetFormat(formatSpec string) logging.Formatter\n```\nSetFormat sets the logging format.\n\n## Types\n\n```go\ntype Config struct {\n\t// Format is the log record format specifier for the Logging instance. If the\n\t// spec is the string \"json\", log records will be formatted as JSON. Any\n\t// other string will be provided to the FormatEncoder. Please see\n\t// fabenc.ParseFormat for details on the supported verbs.\n\t//\n\t// If Format is not provided, a default format that provides basic information will\n\t// be used.\n\tFormat string\n\n\t// LogSpec determines the log levels that are enabled for the logging system. The\n\t// spec must be in a format that can be processed by ActivateSpec.\n\t//\n\t// If LogSpec is not provided, loggers will be enabled at the INFO level.\n\tLogSpec string\n\n\t// Writer is the sink for encoded and formatted log records.\n\t//\n\t// If a Writer is not provided, os.Stderr will be used as the log sink.\n\tWriter io.Writer\n}\n```\nConfig is used to provide dependencies to a Logging instance.\n\n```go\ntype Core struct {\n\tzapcore.LevelEnabler\n\tLevels   *LoggerLevels\n\tEncoders map[Encoding]zapcore.Encoder\n\tSelector EncodingSelector\n\tOutput   zapcore.WriteSyncer\n\tObserver Observer\n}\n```\nCore is a custom implementation of a zapcore.Core. It's a terrible hack that only exists to work around the intersection of state associated with encoders, implementation hiding in zapcore, and implicit, ad-hoc logger initialization within fabric.\n\nIn addition to encoding log entries and fields to a buffer, zap Encoder implementations also need to maintain field state. When zapcore.Core.With is used, the associated encoder is cloned and the fields are added to the encoder. This means that encoder instances cannot be shared across cores.\n\nIn terms of implementation hiding, it's difficult for our FormatEncoder to cleanly wrap the JSON and console implementations from zap as all methods from the zapcore.ObjectEncoder would need to be implemented to delegate to the correct backend.\n\nThis implementation works by associating multiple encoders with a core. When fields are added to the core, the fields are added to all of the encoder implementations. The core also references the logging configuration to determine the proper encoding to use, the writer to delegate to, and the enabled levels.\n\n```go\nfunc (c *Core) Check(e zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry\n```\n\n```go\nfunc (c *Core) Sync() error\n```\n\n```go\nfunc (c *Core) With(fields []zapcore.Field) zapcore.Core\n```\n\n```go\nfunc (c *Core) Write(e zapcore.Entry, fields []zapcore.Field) error\n```\n\n```go\ntype Encoding int8\n```\n\n```go\ntype EncodingSelector interface {\n\tEncoding() Encoding\n}\n```\nEncodingSelector is used to determine whether log records are encoded as JSON or in human readable CONSOLE or LOGFMT formats.\n\n```go\ntype FabricLogger struct {\n\t// contains filtered or unexported fields\n}\n```\nA FabricLogger is an adapter around a zap.SugaredLogger that provides structured logging capabilities while preserving much of the legacy logging behavior.\n\nThe most significant difference between the FabricLogger and the zap.SugaredLogger is that methods without a formatting suffix (f or w) build the log entry message with fmt.Sprintln instead of fmt.Sprint. Without this change, arguments are not separated by spaces.\n\n```go\nfunc MustGetLogger(loggerName string) *FabricLogger\n```\nMustGetLogger creates a logger with the specified name. If an invalid name is provided, the operation will panic.\n\n```go\nfunc NewFabricLogger(l *zap.Logger, options ...zap.Option) *FabricLogger\n```\nNewFabricLogger creates a logger that delegates to the zap.SugaredLogger.\n\n```go\nfunc (f *FabricLogger) Critical(args ...interface{})\n```\nfor backwards compatibility\n\n```go\nfunc (f *FabricLogger) Criticalf(template string, args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) DPanic(args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) DPanicf(template string, args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) DPanicw(msg string, kvPairs ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Debug(args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Debugf(template string, args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Debugw(msg string, kvPairs ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Error(args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Errorf(template string, args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Errorw(msg string, kvPairs ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Fatal(args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Fatalf(template string, args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Fatalw(msg string, kvPairs ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Info(args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Infof(template string, args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Infow(msg string, kvPairs ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) IsEnabledFor(level zapcore.Level) bool\n```\n\n```go\nfunc (f *FabricLogger) Named(name string) *FabricLogger\n```\n\n```go\nfunc (f *FabricLogger) Notice(args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Noticef(template string, args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Panic(args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Panicf(template string, args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Panicw(msg string, kvPairs ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Sync() error\n```\n\n```go\nfunc (f *FabricLogger) Warn(args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Warnf(template string, args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Warning(args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Warningf(template string, args ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) Warnw(msg string, kvPairs ...interface{})\n```\n\n```go\nfunc (f *FabricLogger) With(args ...interface{}) *FabricLogger\n```\n\n```go\nfunc (f *FabricLogger) WithOptions(opts ...zap.Option) *FabricLogger\n```\n\n```go\nfunc (f *FabricLogger) Zap() *zap.Logger\n```\n\n```go\ntype LoggerLevels struct {\n\t// contains filtered or unexported fields\n}\n```\nLoggerLevels tracks the logging level of named loggers.\n\n```go\nfunc (l *LoggerLevels) ActivateSpec(spec string) error\n```\nActivateSpec is used to modify logging levels.\n\nThe logging specification has the following form:\n\n\t[\u003clogger\u003e[,\u003clogger\u003e...]=]\u003clevel\u003e[:[\u003clogger\u003e[,\u003clogger\u003e...]=]\u003clevel\u003e...]\n\n```go\nfunc (l *LoggerLevels) DefaultLevel() zapcore.Level\n```\nDefaultLevel returns the default logging level for loggers that do not have an explicit level set.\n\n```go\nfunc (l *LoggerLevels) Enabled(lvl zapcore.Level) bool\n```\nEnabled function is an enabled check that evaluates the minimum active logging level. It serves as a fast check before the (relatively) expensive Check call in the core.\n\n```go\nfunc (l *LoggerLevels) Level(loggerName string) zapcore.Level\n```\nLevel returns the effective logging level for a logger. If a level has not been explicitly set for the logger, the default logging level will be returned.\n\n```go\nfunc (l *LoggerLevels) Spec() string\n```\nSpec returns a normalized version of the active logging spec.\n\n```go\ntype Logging struct {\n\t*LoggerLevels\n\t// contains filtered or unexported fields\n}\n```\nLogging maintains the state associated with the fabric logging system. It is intended to bridge between the legacy logging infrastructure built around go-logging and the structured, level logging provided by zap.\n\n```go\nvar Global *Logging\n```\n\n```go\nfunc New(c Config) (*Logging, error)\n```\nNew creates a new logging system and initializes it with the provided configuration.\n\n```go\nfunc (s *Logging) Apply(c Config) error\n```\nApply applies the provided configuration to the logging system.\n\n```go\nfunc (s *Logging) Check(e zapcore.Entry, ce *zapcore.CheckedEntry)\n```\n\n```go\nfunc (s *Logging) Encoding() Encoding\n```\nEncoding satisfies the Encoding interface. It determines whether the JSON or CONSOLE encoder should be used by the Core when log records are written.\n\n```go\nfunc (s *Logging) Logger(name string) *FabricLogger\n```\nLogger instantiates a new FabricLogger with the specified name. The name is used to determine which log levels are enabled.\n\n```go\nfunc (s *Logging) SetFormat(format string) error\n```\nSetFormat updates how log records are formatted and encoded. Log entries created after this method has completed will use the new format.\n\nAn error is returned if the log format specification cannot be parsed.\n\n```go\nfunc (s *Logging) SetObserver(observer Observer)\n```\nSetObserver is used to provide a log observer that will be called as log levels are checked or written.. Only a single observer is supported.\n\n```go\nfunc (s *Logging) SetWriter(w io.Writer)\n```\nSetWriter controls which writer formatted log records are written to. Writers, with the exception of an \\*os.File, need to be safe for concurrent use by multiple go routines.\n\n```go\nfunc (s *Logging) Sync() error\n```\nSync satisfies the zapcore.WriteSyncer interface. It is used by the Core to flush log records before terminating the process.\n\n```go\nfunc (s *Logging) Write(b []byte) (int, error)\n```\nWrite satisfies the io.Write contract. It delegates to the writer argument of SetWriter or the Writer field of Config. The Core uses this when encoding log records.\n\n```go\nfunc (s *Logging) WriteEntry(e zapcore.Entry, fields []zapcore.Field)\n```\n\n```go\nfunc (s *Logging) ZapLogger(name string) *zap.Logger\n```\nZapLogger instantiates a new zap.Logger with the specified name. The name is used to determine which log levels are enabled.\n\n```go\ntype Observer interface {\n\tCheck(e zapcore.Entry, ce *zapcore.CheckedEntry)\n\tWriteEntry(e zapcore.Entry, fields []zapcore.Field)\n}\n```\n\n","path":"github.com/eric-erki/https-hyperledger.org/common/flogging","name":"flogging","synopsis":"","isRedistributable":true}
