Documentation ¶
Overview ¶
- Copyright (c) 2019-2021. Abstrium SAS <team (at) pydio.com>
- This file is part of Pydio Cells. *
- Pydio Cells is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version. *
- Pydio Cells is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details. *
- You should have received a copy of the GNU Affero General Public License
- along with Pydio Cells. If not, see <http://www.gnu.org/licenses/>. *
- The latest code can be found at <https://pydio.com>.
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(logDir string, ww ...LogContextWrapper)
- func RFC3369TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- func RegisterConsoleNamedColor(serviceName string, color int)
- func RegisterWriteSyncer(syncer WriteSyncer)
- func SetAuditerInit(f func() *zap.Logger, globalConnInit func(ctx context.Context))
- func SetDynamicDebugLevels(reset, level bool, services ...string)
- func SetLoggerInit(f func() *zap.Logger, globalConnInit func(ctx context.Context))
- func SetSkipServerSync()
- func SetTasksLoggerInit(f func() *zap.Logger, globalConnInit func(ctx context.Context))
- func Warn(msg string, fields ...zapcore.Field)
- type LogContextWrapper
- type LogSyncer
- type WriteSyncer
- type ZapLogger
Constants ¶
const ( ConsoleColorRest = 32 ConsoleColorGrpc = 35 ConsoleColorOther = 36 )
Variables ¶
var ( ConsoleSkipKeys = []string{ common.KeySpanUuid, common.KeySpanRootUuid, common.KeySpanParentUuid, common.KeySchedulerJobId, common.KeySchedulerActionPath, common.KeySchedulerTaskId, common.KeyUsername, common.KeyUserUuid, common.KeyGroupPath, common.KeyProfile, common.KeyRoles, servicecontext.HttpMetaRemoteAddress, servicecontext.HttpMetaUserAgent, servicecontext.HttpMetaContentType, servicecontext.HttpMetaProtocol, } )
var (
EmptyServiceKey = "empty"
)
var (
StdOut *os.File
)
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(logDir string, ww ...LogContextWrapper)
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 WriteSyncer)
RegisterWriteSyncer optional writers for logs
func SetAuditerInit ¶
SetAuditerInit defines what function to use to init the auditer
func SetDynamicDebugLevels ¶
SetDynamicDebugLevels overrides Info level for a specific subset of services
func SetLoggerInit ¶
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 ¶
SetTasksLoggerInit defines what function to use to init the tasks logger
Types ¶
type LogContextWrapper ¶
type WriteSyncer ¶
WriteSyncer implements zapcore.WriteSyncer
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) 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.