log

package
v2.0.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2019 License: AGPL-3.0 Imports: 22 Imported by: 0

README

Pydio LOG

Pydio relies on zap logging framework.

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.

Guidelines

  • When enriching the log with zap fields, always use constants from common/zapfields.go as keys, otherwise the logs won't be usable for analysis
  • Pydio provides some shortcuts to easily generate zap fields for commons pydio objects. Typically when loging info about a tree.Node, one should write: ...Debug("A message", node.Zap())
  • Depending on the level of details required, one can either use Zap() that serializes all accessible information or ZapPath(), ZapUuid() or ZapId() (depending on the relevant info) that simply calls zap.String() with relevant pydio zap id (as seen in common/zapfields.go) and corresponding value.

Conventions

  • it is idiomatic in Go to write error message that start with a lower case letter and do not end with a punctuation mark.

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

This section is empty.

Variables

View Source
var (
	AuditLogger     *zap.Logger
	TasksLoggerImpl *zap.Logger
	StdOut          *os.File
)

Functions

func Auditer

func Auditer(ctx context.Context) *zap.Logger

Auditer returns a zap logger with as much context as possible

func Debug

func Debug(msg string, fields ...zapcore.Field)

func Error

func Error(msg string, fields ...zapcore.Field)

func Fatal

func Fatal(msg string, fields ...zapcore.Field)

func GetAuditId

func GetAuditId(msgId string) zapcore.Field

GetAuditId simply returns a zap field that contains this message id to ease audit log analysis.

func Info

func Info(msg string, fields ...zapcore.Field)

func Init added in v1.2.2

func Init()

func Logger

func Logger(ctx context.Context) *zap.Logger

Logger returns a zap logger with as much context as possible.

func RFC3369TimeEncoder

func RFC3369TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)

RFC3369TimeEncoder serializes a time.Time to an RFC3339-formatted string

func RegisterWriteSyncer

func RegisterWriteSyncer(syncer WriteSyncer)

Register optional writers for logs

func TasksLogger added in v1.4.0

func TasksLogger(ctx context.Context) *zap.Logger

TasksLogger returns a zap logger with as much context as possible.

Types

type LogSyncer

type LogSyncer struct {
	// contains filtered or unexported fields
}

func NewLogSyncer

func NewLogSyncer(serviceName string) *LogSyncer

func (*LogSyncer) Write

func (l *LogSyncer) Write(p []byte) (n int, err error)

type WriteSyncer

type WriteSyncer interface {
	io.Writer
	Sync() error
}

Same as zapcore.WriteSyncer but without dependency

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL