logging

package
v0.0.0-...-6e91cfd Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LoggerSpecEnvVar is the environment variable that controls what kind of logger we
	// want.  If the value is "file" we will only log to file.  If the value is "both", we
	// log to console and file.  If the value is "console" we log to console only.
	// "container"
	LoggerSpecEnvVar = "GG_LOGGER"

	// LogDirEnvVar is the environment variable that controls which directory logging
	// will take place in.  If this is unset we do not log to file.make
	LogDirEnvVar = "GG_LOG_DIR"

	// LogFileSizeEnvVar specifies max log file size in megabytes
	LogFileSizeEnvVar = "GG_LOG_FILE_SIZE_MB"

	// LogFileMaxAgeEnvVar is the maximum number of days we will keep log files around.
	LogFileMaxAgeEnvVar = "GG_LOG_FILE_MAX_AGE_DAYS"
)

Variables

This section is empty.

Functions

func Get

func Get() *zap.Logger

Get the logger

func GetLevel

func GetLevel() zapcore.Level

GetLevel returns the current log level

func GetLogDir

func GetLogDir() string

GetLogDir returns the directory we log to

func SetLevel

func SetLevel(level zapcore.Level)

SetLevel sets the log level

func SetLevelTemporarily

func SetLevelTemporarily(level zapcore.Level, d time.Duration) (time.Duration, error)

SetLevelTemporarily sets the loglevel to `level` for `d` duration.

Types

type FileWriter

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

FileWriter writes logs to the filesystem.

func NewFileWriter

func NewFileWriter(c FileWriterConfig) *FileWriter

NewFileWriter creates a new FileWriter given a FileWriterConfig

func (*FileWriter) Close

func (w *FileWriter) Close() error

Close the logger.

func (*FileWriter) Write

func (w *FileWriter) Write(msg []byte) (int, error)

type FileWriterConfig

type FileWriterConfig struct {
	LogDirName  string
	LogFileName string
	Compress    bool
	// If MaxDaysToKeep is 0 we keep the all log files regardless of age
	MaxTimeTimeToKeep   time.Duration
	MaxLogFileSizeBytes int64
}

FileWriterConfig contains the configuration for a FileWriter

Jump to

Keyboard shortcuts

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