logger

package
v0.0.0-...-b702281 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 10 Imported by: 28

Documentation

Index

Constants

View Source
const (
	LOGLEVEL_ENV_VAR             = "ECS_LOGLEVEL"
	LOGLEVEL_ON_INSTANCE_ENV_VAR = "ECS_LOGLEVEL_ON_INSTANCE"
	LOGFILE_ENV_VAR              = "ECS_LOGFILE"
	LOG_DRIVER_ENV_VAR           = "ECS_LOG_DRIVER"
	LOG_ROLLOVER_TYPE_ENV_VAR    = "ECS_LOG_ROLLOVER_TYPE"
	LOG_OUTPUT_FORMAT_ENV_VAR    = "ECS_LOG_OUTPUT_FORMAT"
	LOG_MAX_FILE_SIZE_ENV_VAR    = "ECS_LOG_MAX_FILE_SIZE_MB"
	LOG_MAX_ROLL_COUNT_ENV_VAR   = "ECS_LOG_MAX_ROLL_COUNT"

	DEFAULT_LOGLEVEL                         = "info"
	DEFAULT_LOGLEVEL_WHEN_DRIVER_SET         = "off"
	DEFAULT_ROLLOVER_TYPE                    = "date"
	DEFAULT_OUTPUT_FORMAT                    = logFmt
	DEFAULT_TIMESTAMP_FORMAT                 = time.RFC3339
	DEFAULT_MAX_FILE_SIZE            float64 = 10
	DEFAULT_MAX_ROLL_COUNT           int     = 24
	DEFAULT_LOGTO_STDOUT                     = true
)

Variables

View Source
var Config *logConfig

Functions

func Critical

func Critical(message string, fields ...Fields)

func Debug

func Debug(message string, fields ...Fields)

func Error

func Error(message string, fields ...Fields)

func GetLevel

func GetLevel() string

GetLevel gets the log level

func Info

func Info(message string, fields ...Fields)

func InitSeelog

func InitSeelog()

InitSeelog registers custom logging formats, updates the internal Config struct and reloads the global logger. This should only be called once, as external callers should use the Config struct over environment variables directly.

func SetConfigLogFile

func SetConfigLogFile(logFile string)

SetConfigLogFile sets the default output file of the logger.

func SetConfigMaxFileSizeMB

func SetConfigMaxFileSizeMB(maxSizeInMB float64)

SetConfigMaxFileSizeMB sets the max file size of a log file in Megabytes before the logger rotates to a new file.

func SetConfigOutputFormat

func SetConfigOutputFormat(outputFormat string)

SetConfigOutputFormat sets the output format of the logger. e.g. json, xml, etc.

func SetDriverLogLevel

func SetDriverLogLevel(driverLogLevel string)

SetDriverLogLevel explicitly sets the log level for a custom driver.

func SetInstanceLogLevel

func SetInstanceLogLevel(instanceLogLevel string)

SetInstanceLogLevel explicitly sets the log level for instance logs.

func SetLogToStdout

func SetLogToStdout(duplicate bool)

SetLogToStdout decides whether the logger should write to stdout using the <console/> tag in addition to logfiles that are set up.

func SetRolloverType

func SetRolloverType(rolloverType string)

SetRolloverType sets the logging rollover constraint. This should be either size or date. Logger will roll to a new log file based on this constraint.

func SetTimestampFormat

func SetTimestampFormat(format string)

SetTimestampFormat sets the time formatting for custom seelog formatters. It will expect a valid time format such as time.RFC3339 or "2006-01-02T15:04:05.000".

func StartRuntimeStatsLogger

func StartRuntimeStatsLogger(runtimeStatsLogFile string) (flush func())

func Trace

func Trace(message string, fields ...Fields)

func Warn

func Warn(message string, fields ...Fields)

Types

type Fields

type Fields map[string]interface{}

func (Fields) Merge

func (f Fields) Merge(f2 Fields)

type StructuredLogger

type StructuredLogger interface {
	Trace(message string, fields ...Fields)
	Debug(message string, fields ...Fields)
	Info(message string, fields ...Fields)
	Warn(message string, fields ...Fields)
	Error(message string, fields ...Fields)
	Critical(message string, fields ...Fields)
}

Directories

Path Synopsis
mocks
Package mock_audit is a generated GoMock package.
Package mock_audit is a generated GoMock package.
Package mock_seelog is a generated GoMock package.
Package mock_seelog is a generated GoMock package.

Jump to

Keyboard shortcuts

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