Documentation ¶
Overview ¶
Package log define and configure the Pydio loggers based on zap.
We mainly use 2 loggers that are defined in this package and used throughout the backend: - A syslog logger: it should be used to log technical information. - An audit logger: it only logs some very precise information at strategic places and is used to monitor the Application from a business point of view. Audit logs are among others used for GRDP compliance.
WARNING: you should not modify nor remove any of the audit log.
Index ¶
- Constants
- Variables
- func DangerouslyZapSmallSlice(key string, value interface{}) zapcore.Field
- func Debug(msg string, fields ...zapcore.Field)
- func Error(msg string, fields ...zapcore.Field)
- func Fatal(msg string, fields ...zapcore.Field)
- func GetAuditId(msgId string) zapcore.Field
- func Info(msg string, fields ...zapcore.Field)
- func Init(svc otel.Service, conf []LoggerConfig, ww ...ContextWrapper)
- func LoadCores(ctx context.Context, svc otel.Service, cfg []LoggerConfig) (cores []zapcore.Core, closers []io.Closer, hasDebug bool)
- func RFC3369TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- func RegisterConsoleNamedColor(serviceName string, color int)
- func RegisterWriteSyncer(syncer LoggerConfig)
- func ReloadMainLogger(scv otel.Service, cfg []LoggerConfig)
- func SetAuditerInit(f LoggerInitializer, globalConnInit func(ctx context.Context))
- func SetDynamicDebugLevels(reset, level bool, services ...string)
- func SetLoggerInit(f LoggerInitializer, globalConnInit func(ctx context.Context))
- func SetSkipServerSync()
- func SetTasksLoggerInit(f LoggerInitializer, globalConnInit func(ctx context.Context))
- func Warn(msg string, fields ...zapcore.Field)
- type ContextWrapper
- type CoreCloser
- type CoreURLOpener
- type LoggerConfig
- type LoggerInitializer
- type LoggerPool
- type SyncURLOpener
- type URLMux
- func (mux *URLMux) OpenCore(ctx context.Context, rawURL string, level zapcore.LevelEnabler, ...) (CoreCloser, error)
- func (mux *URLMux) OpenSync(ctx context.Context, rawURL string) (WriteSyncerCloser, error)
- func (mux *URLMux) RegisterCore(scheme string, opener CoreURLOpener)
- func (mux *URLMux) RegisterSync(scheme string, opener SyncURLOpener)
- type WriteSyncer
- type WriteSyncerCloser
- type ZapLogger
Constants ¶
const ( ConsoleColorRest = 32 ConsoleColorGrpc = 35 ConsoleColorOther = 36 )
Variables ¶
var ( JSONEncoder zapcore.Encoder ConsoleEncoder zapcore.Encoder )
var ( EncoderHttpMetaKeys []string ConsoleSkipKeys = []string{ common.KeySpanOtel, common.KeySpanUuid, common.KeySpanRootUuid, common.KeySpanParentUuid, common.KeySchedulerJobId, common.KeySchedulerActionPath, common.KeySchedulerActionTags, common.KeySchedulerTaskId, common.KeyUsername, common.KeyUserUuid, common.KeyGroupPath, common.KeyProfile, common.KeyRoles, } )
var ( ReadyLogSyncerContext context.Context StdOut *os.File )
var (
EmptyServiceKey = "empty"
)
Functions ¶
func DangerouslyZapSmallSlice ¶
DangerouslyZapSmallSlice is a simple clone for zap.Any, allowing the linter to consider the slice zap as legitimate. It informs the developer to make sure that the slice passed must be small, otherwise it can hang the internal logger
func GetAuditId ¶
GetAuditId simply returns a zap field that contains this message id to ease audit log analysis.
func Init ¶
func Init(svc otel.Service, conf []LoggerConfig, ww ...ContextWrapper)
Init for the log package - called by the main
func RFC3369TimeEncoder ¶
func RFC3369TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
RFC3369TimeEncoder serializes a time.Time to an RFC3339-formatted string
func RegisterConsoleNamedColor ¶
RegisterConsoleNamedColor allows external registration of colors based on Logger Name.
func RegisterWriteSyncer ¶
func RegisterWriteSyncer(syncer LoggerConfig)
RegisterWriteSyncer optional writers for logs
func ReloadMainLogger ¶
func ReloadMainLogger(scv otel.Service, cfg []LoggerConfig)
ReloadMainLogger passes an updated config and force logger reset
func SetAuditerInit ¶
func SetAuditerInit(f LoggerInitializer, globalConnInit func(ctx context.Context))
SetAuditerInit defines what function to use to init the auditer
func SetDynamicDebugLevels ¶
SetDynamicDebugLevels overrides Info level for a specific subset of services
func SetLoggerInit ¶
func SetLoggerInit(f LoggerInitializer, globalConnInit func(ctx context.Context))
SetLoggerInit defines what function to use to init the logger
func SetSkipServerSync ¶
func SetSkipServerSync()
SetSkipServerSync can disable the core syncing to cells service Must be called before initialization
func SetTasksLoggerInit ¶
func SetTasksLoggerInit(f LoggerInitializer, globalConnInit func(ctx context.Context))
SetTasksLoggerInit defines what function to use to init the tasks logger
Types ¶
type ContextWrapper ¶
type CoreURLOpener ¶
type CoreURLOpener interface {
OpenCore(ctx context.Context, u *url.URL, level zapcore.LevelEnabler, svc otel.Service) (CoreCloser, error)
}
CoreURLOpener represents types than can open Registries based on a URL.
type LoggerConfig ¶
type LoggerConfig struct { Level string `json:"level" yaml:"level"` Encoding string `json:"encoding" yaml:"encoding"` Outputs []string `json:"outputs" yaml:"outputs"` Filters map[string]string `json:"filters,omitempty" yaml:"filters,omitempty"` }
func DefaultLegacyConfig ¶
func DefaultLegacyConfig(level, encoding, logToDir string) []LoggerConfig
func (LoggerConfig) Enabler ¶
func (c LoggerConfig) Enabler() zapcore.LevelEnabler
Enabler creates a dynamic enabler based on Level text value. Level may contain ">=debug" or "<debug" or "=debug" No comparator defaults to ">=", i.e "info" means Info and higher
func (LoggerConfig) Encoder ¶
func (c LoggerConfig) Encoder() zapcore.Encoder
Encoder computes encoder based on textual Encoder key Currently supported are "json" and "console"
type LoggerInitializer ¶
type LoggerPool ¶
type SyncURLOpener ¶
type SyncURLOpener interface {
OpenSync(ctx context.Context, u *url.URL) (WriteSyncerCloser, error)
}
SyncURLOpener implements WriteSyncerCloser opener
type URLMux ¶
type URLMux struct {
// contains filtered or unexported fields
}
URLMux is a URL opener multiplexer. It matches the scheme of the URLs against a set of registered schemes and calls the opener that matches the URL's scheme. See https://gocloud.dev/concepts/urls/ for more information.
The zero value is a multiplexer with no registered schemes.
func DefaultURLMux ¶
func DefaultURLMux() *URLMux
DefaultURLMux returns the URLMux used by OpenTopic and OpenSubscription.
Driver packages can use this to register their TopicURLOpener and/or SubscriptionURLOpener on the mux.
func (*URLMux) OpenCore ¶
func (mux *URLMux) OpenCore(ctx context.Context, rawURL string, level zapcore.LevelEnabler, svc otel.Service) (CoreCloser, error)
OpenCore calls OpenURL with the URL parsed from urlstr. OpenStore is safe to call from multiple goroutines.
func (*URLMux) OpenSync ¶
OpenSync calls OpenURL with the URL parsed from urlstr. OpenStore is safe to call from multiple goroutines.
func (*URLMux) RegisterCore ¶
func (mux *URLMux) RegisterCore(scheme string, opener CoreURLOpener)
RegisterCore registers the opener with the given scheme. If an opener already exists for the scheme, Register panics.
func (*URLMux) RegisterSync ¶
func (mux *URLMux) RegisterSync(scheme string, opener SyncURLOpener)
RegisterSync register an opener for a WriteSyncer
type WriteSyncer ¶
WriteSyncer implements zapcore.WriteSyncer
type WriteSyncerCloser ¶
type WriteSyncerCloser interface { zapcore.WriteSyncer io.Closer }
type ZapLogger ¶
type ZapLogger interface { Named(s string) ZapLogger WithOptions(opts ...zap.Option) ZapLogger With(fields ...zap.Field) ZapLogger Debug(msg string, fields ...zap.Field) Info(msg string, fields ...zap.Field) Warn(msg string, fields ...zap.Field) Error(msg string, fields ...zap.Field) DPanic(msg string, fields ...zap.Field) Panic(msg string, fields ...zap.Field) Fatal(msg string, fields ...zap.Field) Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Sugar() *zap.SugaredLogger Check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry Sync() error Core() zapcore.Core }
func BasicContextWrapper ¶
BasicContextWrapper creates a Named logger from serviceName found in context
func TasksLogger ¶
TasksLogger returns a zap logger with as much context as possible.