log

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2019 License: MIT Imports: 19 Imported by: 1,966

Documentation

Index

Constants

View Source
const (
	Ldate          = 1 << iota // the date in the local time zone: 2009/01/23
	Ltime                      // the time in the local time zone: 01:23:23
	Lmicroseconds              // microsecond resolution: 01:23:23.123123.  assumes Ltime.
	Llongfile                  // full file name and line number: /a/logger/c/d.go:23
	Lshortfile                 // final file name element and line number: d.go:23. overrides Llongfile
	Lfuncname                  // function name of the caller: runtime.Caller()
	Lshortfuncname             // last part of the function name
	LUTC                       // if Ldate or Ltime is set, use UTC rather than the local time zone
	Llevelinitial              // Initial character of the provided level in brackets eg. [I] for info
	Llevel                     // Provided level in brackets [INFO]

	// Last 20 characters of the filename
	Lmedfile = Lshortfile | Llongfile

	// LstdFlags is the initial value for the standard logger
	LstdFlags = Ldate | Ltime | Lmedfile | Lshortfuncname | Llevelinitial
)

These flags define which text to prefix to each log entry generated by the Logger. Bits are or'ed together to control what's printed. There is no control over the order they appear (the order listed here) or the format they present (as described in the comments). The prefix is followed by a colon only if more than time is stated is specified. For example, flags Ldate | Ltime produce, 2009/01/23 01:23:23 message. The standard is: 2009/01/23 01:23:23 ...a/logger/c/d.go:23:runtime.Caller() [I]: message

Variables

View Source
var (
	// DEFAULT is the name of the default logger
	DEFAULT = "default"
	// NamedLoggers map of named loggers
	NamedLoggers loggerMap
)
View Source
var CanColorStderr = true

CanColorStderr reports if we can color the Stderr

View Source
var CanColorStdout = true

CanColorStdout reports if we can color the Stdout Although we could do terminal sniffing and the like - in reality most tools on *nix are happy to display ansi colors. We will terminal sniff on Windows in console_windows.go

Functions

func Close

func Close()

Close closes all the loggers

func ColorBytes added in v1.9.0

func ColorBytes(attrs ...ColorAttribute) []byte

ColorBytes converts a list of ColorAttributes to a byte array

func ColorFprintf added in v1.9.0

func ColorFprintf(w io.Writer, format string, args ...interface{}) (int, error)

ColorFprintf will write to the provided writer similar to ColorSprintf

func ColorSprintf added in v1.9.0

func ColorSprintf(format string, args ...interface{}) string

ColorSprintf returns a colored string from a format and arguments arguments will be wrapped in ColoredValues to protect against color spoofing

func ColorString added in v1.9.0

func ColorString(attrs ...ColorAttribute) string

ColorString converts a list of ColorAttributes to a color string

func Critical

func Critical(format string, v ...interface{})

Critical records critical log

func CriticalWithSkip added in v1.9.0

func CriticalWithSkip(skip int, format string, v ...interface{})

CriticalWithSkip records critical log from "skip" calls back from this function

func Debug

func Debug(format string, v ...interface{})

Debug records debug log

func DelLogger added in v1.0.2

func DelLogger(name string) error

DelLogger removes the named sublogger from the default logger

func DelNamedLogger added in v1.9.0

func DelNamedLogger(name string)

DelNamedLogger closes and deletes the named logger

func Error

func Error(format string, v ...interface{})

Error records error log

func ErrorWithSkip added in v1.9.0

func ErrorWithSkip(skip int, format string, v ...interface{})

ErrorWithSkip records error log from "skip" calls back from this function

func Fatal

func Fatal(format string, v ...interface{})

Fatal records fatal log and exit process

func FatalWithSkip added in v1.9.0

func FatalWithSkip(skip int, format string, v ...interface{})

FatalWithSkip records fatal log from "skip" calls back from this function

func FlagsFromString added in v1.9.0

func FlagsFromString(from string) int

FlagsFromString takes a comma separated list of flags and returns the flags for this string

func Info

func Info(format string, v ...interface{})

Info records info log

func IsCritical added in v1.9.0

func IsCritical() bool

IsCritical returns true if at least one logger is CRITICAL

func IsDebug added in v1.9.0

func IsDebug() bool

IsDebug returns true if at least one logger is DEBUG

func IsErrDuplicateName added in v1.9.0

func IsErrDuplicateName(err error) bool

IsErrDuplicateName checks if an error is a ErrDuplicateName.

func IsErrTimeout added in v1.9.0

func IsErrTimeout(err error) bool

IsErrTimeout checks if an error is a ErrTimeout.

func IsErrUnknownProvider added in v1.9.0

func IsErrUnknownProvider(err error) bool

IsErrUnknownProvider checks if an error is a ErrUnknownProvider.

func IsError added in v1.9.0

func IsError() bool

IsError returns true if at least one logger is ERROR

func IsFatal added in v1.9.0

func IsFatal() bool

IsFatal returns true if at least one logger is FATAL

func IsInfo added in v1.9.0

func IsInfo() bool

IsInfo returns true if at least one logger is INFO

func IsTrace added in v1.9.0

func IsTrace() bool

IsTrace returns true if at least one logger is TRACE

func IsWarn added in v1.9.0

func IsWarn() bool

IsWarn returns true if at least one logger is WARN

func Levels added in v1.9.0

func Levels() []string

Levels returns all the possible logging levels

func Log added in v1.9.0

func Log(skip int, level Level, format string, v ...interface{})

Log a message with defined skip and at logging level A skip of 0 refers to the caller of this command

func NewNamedLogger added in v1.9.0

func NewNamedLogger(name string, bufLen int64, subname, provider, config string) error

NewNamedLogger creates a new named logger for a given configuration

func Register

func Register(name string, log loggerProvider)

Register registers given logger provider to providers.

func Stack added in v1.9.0

func Stack(skip int) string

Stack will skip back the provided number of frames and return a stack trace with source code. Although we could just use debug.Stack(), this routine will return the source code and skip back the provided number of frames - i.e. allowing us to ignore preceding function calls. A skip of 0 returns the stack trace for the calling function, not including this call. If the problem is a lack of memory of course all this is not going to work...

func Trace

func Trace(format string, v ...interface{})

Trace records trace log

func Warn

func Warn(format string, v ...interface{})

Warn records warning log

Types

type ChannelledLog added in v1.9.0

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

ChannelledLog represents a cached channel to a LoggerProvider

func NewChannelledLog added in v1.9.0

func NewChannelledLog(name, provider, config string, bufferLength int64) (*ChannelledLog, error)

NewChannelledLog a new logger instance with given logger provider and config.

func (*ChannelledLog) Close added in v1.9.0

func (l *ChannelledLog) Close()

Close this ChannelledLog

func (*ChannelledLog) Flush added in v1.9.0

func (l *ChannelledLog) Flush()

Flush this ChannelledLog

func (*ChannelledLog) GetLevel added in v1.9.0

func (l *ChannelledLog) GetLevel() Level

GetLevel gets the level of this ChannelledLog

func (*ChannelledLog) GetName added in v1.9.0

func (l *ChannelledLog) GetName() string

GetName returns the name of this ChannelledLog

func (*ChannelledLog) GetStacktraceLevel added in v1.9.0

func (l *ChannelledLog) GetStacktraceLevel() Level

GetStacktraceLevel gets the level of this ChannelledLog

func (*ChannelledLog) LogEvent added in v1.9.0

func (l *ChannelledLog) LogEvent(event *Event) error

LogEvent logs an event to this ChannelledLog

func (*ChannelledLog) Start added in v1.9.0

func (l *ChannelledLog) Start()

Start processing the ChannelledLog

type ColorAttribute added in v1.9.0

type ColorAttribute int

ColorAttribute defines a single SGR Code

const (
	Reset ColorAttribute = iota
	Bold
	Faint
	Italic
	Underline
	BlinkSlow
	BlinkRapid
	ReverseVideo
	Concealed
	CrossedOut
)

Base ColorAttributes

const (
	FgBlack ColorAttribute = iota + 30
	FgRed
	FgGreen
	FgYellow
	FgBlue
	FgMagenta
	FgCyan
	FgWhite
)

Foreground text colors

const (
	FgHiBlack ColorAttribute = iota + 90
	FgHiRed
	FgHiGreen
	FgHiYellow
	FgHiBlue
	FgHiMagenta
	FgHiCyan
	FgHiWhite
)

Foreground Hi-Intensity text colors

const (
	BgBlack ColorAttribute = iota + 40
	BgRed
	BgGreen
	BgYellow
	BgBlue
	BgMagenta
	BgCyan
	BgWhite
)

Background text colors

const (
	BgHiBlack ColorAttribute = iota + 100
	BgHiRed
	BgHiGreen
	BgHiYellow
	BgHiBlue
	BgHiMagenta
	BgHiCyan
	BgHiWhite
)

Background Hi-Intensity text colors

func ColorAttributeFromString added in v1.9.0

func ColorAttributeFromString(from string) ColorAttribute

ColorAttributeFromString will return a ColorAttribute given a string

func (*ColorAttribute) String added in v1.9.0

func (c *ColorAttribute) String() string

type ColorFormatted added in v1.9.0

type ColorFormatted interface {
	// ColorFormat provides the colored representation of the value
	ColorFormat(s fmt.State)
}

ColorFormatted structs provide their own colored string when formatted with ColorSprintf

type ColoredValue added in v1.9.0

type ColoredValue struct {
	Value *interface{}
	// contains filtered or unexported fields
}

ColoredValue will Color the provided value

func ColoredMethod added in v1.9.0

func ColoredMethod(method string) *ColoredValue

ColoredMethod addes colors for HtTP methos on log

func ColoredStatus added in v1.9.0

func ColoredStatus(status int, s ...string) *ColoredValue

ColoredStatus addes colors for HTTP status

func ColoredTime added in v1.9.0

func ColoredTime(duration time.Duration) *ColoredValue

ColoredTime addes colors for time on log

func NewColoredIDValue added in v1.9.0

func NewColoredIDValue(value interface{}) *ColoredValue

NewColoredIDValue is a helper function to create a ColoredValue from a Value The Value will be colored with FgCyan If a ColoredValue is provided it is not changed

func NewColoredValue added in v1.9.0

func NewColoredValue(value interface{}, color ...ColorAttribute) *ColoredValue

NewColoredValue is a helper function to create a ColoredValue from a Value If no color is provided it defaults to Bold with standard Reset If a ColoredValue is provided it is not changed

func NewColoredValueBytes added in v1.9.0

func NewColoredValueBytes(value interface{}, colorBytes *[]byte) *ColoredValue

NewColoredValueBytes creates a value from the provided value with color bytes If a ColoredValue is provided it is not changed

func NewColoredValuePointer added in v1.9.0

func NewColoredValuePointer(value *interface{}, color ...ColorAttribute) *ColoredValue

NewColoredValuePointer is a helper function to create a ColoredValue from a Value Pointer If no color is provided it defaults to Bold with standard Reset If a ColoredValue is provided it is not changed

func (*ColoredValue) Format added in v1.9.0

func (cv *ColoredValue) Format(s fmt.State, c rune)

Format will format the provided value and protect against ANSI color spoofing within the value If the wrapped value is ColorFormatted and the format is "%-v" then its ColorString will be used. It is presumed that this ColorString is safe.

func (*ColoredValue) SetColorBytes added in v1.9.0

func (cv *ColoredValue) SetColorBytes(colorBytes []byte)

SetColorBytes will allow a user to set the colorBytes of a colored value

func (*ColoredValue) SetColorBytesPointer added in v1.9.0

func (cv *ColoredValue) SetColorBytesPointer(colorBytes *[]byte)

SetColorBytesPointer will allow a user to set the colorBytes pointer of a colored value

func (*ColoredValue) SetResetBytes added in v1.9.0

func (cv *ColoredValue) SetResetBytes(resetBytes []byte)

SetResetBytes will allow a user to set the resetBytes pointer of a colored value

func (*ColoredValue) SetResetBytesPointer added in v1.9.0

func (cv *ColoredValue) SetResetBytesPointer(resetBytes *[]byte)

SetResetBytesPointer will allow a user to set the resetBytes pointer of a colored value

type ConnLogger added in v1.9.0

type ConnLogger struct {
	WriterLogger
	ReconnectOnMsg bool   `json:"reconnectOnMsg"`
	Reconnect      bool   `json:"reconnect"`
	Net            string `json:"net"`
	Addr           string `json:"addr"`
}

ConnLogger implements LoggerProvider. it writes messages in keep-live tcp connection.

func (*ConnLogger) Flush added in v1.9.0

func (log *ConnLogger) Flush()

Flush does nothing for this implementation

func (*ConnLogger) GetName added in v1.9.0

func (log *ConnLogger) GetName() string

GetName returns the default name for this implementation

func (*ConnLogger) Init added in v1.9.0

func (log *ConnLogger) Init(jsonconfig string) error

Init inits connection writer with json config. json config only need key "level".

type ConsoleLogger added in v1.9.0

type ConsoleLogger struct {
	WriterLogger
	Stderr bool `json:"stderr"`
}

ConsoleLogger implements LoggerProvider and writes messages to terminal.

func (*ConsoleLogger) Flush added in v1.9.0

func (log *ConsoleLogger) Flush()

Flush when log should be flushed

func (*ConsoleLogger) GetName added in v1.9.0

func (log *ConsoleLogger) GetName() string

GetName returns the default name for this implementation

func (*ConsoleLogger) Init added in v1.9.0

func (log *ConsoleLogger) Init(config string) error

Init inits connection writer with json config. json config only need key "level".

type ErrDuplicateName added in v1.9.0

type ErrDuplicateName struct {
	Name string
}

ErrDuplicateName represents a Duplicate Name error

func (ErrDuplicateName) Error added in v1.9.0

func (err ErrDuplicateName) Error() string

type ErrTimeout added in v1.9.0

type ErrTimeout struct {
	Name     string
	Provider string
}

ErrTimeout represents a "Timeout" kind of error.

func (ErrTimeout) Error added in v1.9.0

func (err ErrTimeout) Error() string

type ErrUnknownProvider added in v1.9.0

type ErrUnknownProvider struct {
	Provider string
}

ErrUnknownProvider represents a "Unknown Provider" kind of error.

func (ErrUnknownProvider) Error added in v1.9.0

func (err ErrUnknownProvider) Error() string

type Event added in v1.9.0

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

Event represents a logging event

type EventLogger added in v1.9.0

type EventLogger interface {
	LogEvent(event *Event) error
	Close()
	Flush()
	GetLevel() Level
	GetStacktraceLevel() Level
	GetName() string
}

EventLogger represents the behaviours of a logger

type FileLogger added in v1.9.0

type FileLogger struct {
	WriterLogger

	// The opened file
	Filename string `json:"filename"`

	// Rotate at size
	Maxsize int `json:"maxsize"`

	// Rotate daily
	Daily   bool  `json:"daily"`
	Maxdays int64 `json:"maxdays"`

	Rotate bool `json:"rotate"`

	Compress         bool `json:"compress"`
	CompressionLevel int  `json:"compressionLevel"`
	// contains filtered or unexported fields
}

FileLogger implements LoggerProvider. It writes messages by lines limit, file size limit, or time frequency.

func (*FileLogger) DoRotate added in v1.9.0

func (log *FileLogger) DoRotate() error

DoRotate means it need to write file in new file. new file name like xx.log.2013-01-01.2

func (*FileLogger) Flush added in v1.9.0

func (log *FileLogger) Flush()

Flush flush file logger. there are no buffering messages in file logger in memory. flush file means sync file from disk.

func (*FileLogger) GetName added in v1.9.0

func (log *FileLogger) GetName() string

GetName returns the default name for this implementation

func (*FileLogger) Init added in v1.9.0

func (log *FileLogger) Init(config string) error

Init file logger with json config. config like:

{
"filename":"log/gogs.log",
"maxsize":1<<30,
"daily":true,
"maxdays":15,
"rotate":true
}

func (*FileLogger) StartLogger added in v1.9.0

func (log *FileLogger) StartLogger() error

StartLogger start file logger. create log file and set to locker-inside file writer.

type Level added in v1.9.0

type Level int

Level is the level of the logger

const (
	// TRACE represents the lowest log level
	TRACE Level = iota
	// DEBUG is for debug logging
	DEBUG
	// INFO is for information
	INFO
	// WARN is for warning information
	WARN
	// ERROR is for error reporting
	ERROR
	// CRITICAL is for critical errors
	CRITICAL
	// FATAL is for fatal errors
	FATAL
	// NONE is for no logging
	NONE
)

func FromString added in v1.9.0

func FromString(level string) Level

FromString takes a level string and returns a Level

func GetLevel added in v1.9.0

func GetLevel() Level

GetLevel returns the minimum logger level

func GetStacktraceLevel added in v1.9.0

func GetStacktraceLevel() Level

GetStacktraceLevel returns the minimum logger level

func (Level) MarshalJSON added in v1.9.0

func (l Level) MarshalJSON() ([]byte, error)

MarshalJSON takes a Level and turns it into text

func (Level) String added in v1.9.0

func (l Level) String() string

func (*Level) UnmarshalJSON added in v1.9.0

func (l *Level) UnmarshalJSON(b []byte) error

UnmarshalJSON takes text and turns it into a Level

type Logger

type Logger struct {
	*MultiChannelledLog
	// contains filtered or unexported fields
}

Logger is default logger in the Gitea application. it can contain several providers and log message into all providers.

func GetLogger added in v1.9.0

func GetLogger(name string) *Logger

GetLogger returns either a named logger or the default logger

func NewLogger

func NewLogger(bufLen int64, name, provider, config string) *Logger

NewLogger create a logger for the default logger

func (*Logger) Critical

func (l *Logger) Critical(format string, v ...interface{})

Critical records critical log

func (*Logger) CriticalWithSkip added in v1.9.0

func (l *Logger) CriticalWithSkip(skip int, format string, v ...interface{})

CriticalWithSkip records critical log from "skip" calls back from this function

func (*Logger) Debug

func (l *Logger) Debug(format string, v ...interface{})

Debug records debug log

func (*Logger) DelLogger

func (l *Logger) DelLogger(name string) (bool, error)

DelLogger deletes a sublogger from this logger.

func (*Logger) Error

func (l *Logger) Error(format string, v ...interface{})

Error records error log

func (*Logger) ErrorWithSkip added in v1.9.0

func (l *Logger) ErrorWithSkip(skip int, format string, v ...interface{})

ErrorWithSkip records error log from "skip" calls back from this function

func (*Logger) Fatal

func (l *Logger) Fatal(format string, v ...interface{})

Fatal records fatal log and exit the process

func (*Logger) FatalWithSkip added in v1.9.0

func (l *Logger) FatalWithSkip(skip int, format string, v ...interface{})

FatalWithSkip records fatal log from "skip" calls back from this function and exits the process

func (*Logger) Info

func (l *Logger) Info(format string, v ...interface{})

Info records information log

func (*Logger) Log added in v1.9.0

func (l *Logger) Log(skip int, level Level, format string, v ...interface{}) error

Log msg at the provided level with the provided caller defined by skip (0 being the function that calls this function)

func (*Logger) SendLog added in v1.9.0

func (l *Logger) SendLog(level Level, caller, filename string, line int, msg string, stack string) error

SendLog sends a log event at the provided level with the information given

func (*Logger) SetLogger

func (l *Logger) SetLogger(name, provider, config string) error

SetLogger sets new logger instance with given logger provider and config.

func (*Logger) Trace

func (l *Logger) Trace(format string, v ...interface{})

Trace records trace log

func (*Logger) Warn

func (l *Logger) Warn(format string, v ...interface{})

Warn records warning log

type LoggerAsWriter added in v1.8.0

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

LoggerAsWriter is a io.Writer shim around the gitea log

func NewLoggerAsWriter added in v1.8.0

func NewLoggerAsWriter(level string, ourLoggers ...*Logger) *LoggerAsWriter

NewLoggerAsWriter creates a Writer representation of the logger with setable log level

func (*LoggerAsWriter) Log added in v1.8.0

func (l *LoggerAsWriter) Log(msg string)

Log takes a given string and logs it at the set log-level

func (*LoggerAsWriter) Write added in v1.8.0

func (l *LoggerAsWriter) Write(p []byte) (int, error)

Write implements the io.Writer interface to allow spoofing of macaron

type LoggerProvider added in v1.9.0

type LoggerProvider interface {
	Init(config string) error
	EventLogger
}

LoggerProvider represents behaviors of a logger provider.

func NewConn

func NewConn() LoggerProvider

NewConn creates new ConnLogger returning as LoggerProvider.

func NewConsoleLogger added in v1.9.0

func NewConsoleLogger() LoggerProvider

NewConsoleLogger create ConsoleLogger returning as LoggerProvider.

func NewFileLogger added in v1.9.0

func NewFileLogger() LoggerProvider

NewFileLogger create a FileLogger returning as LoggerProvider.

func NewSMTPLogger added in v1.9.0

func NewSMTPLogger() LoggerProvider

NewSMTPLogger creates smtp writer.

type MultiChannelledLog added in v1.9.0

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

MultiChannelledLog represents a cached channel to a LoggerProvider

func NewMultiChannelledLog added in v1.9.0

func NewMultiChannelledLog(name string, bufferLength int64) *MultiChannelledLog

NewMultiChannelledLog a new logger instance with given logger provider and config.

func (*MultiChannelledLog) AddLogger added in v1.9.0

func (m *MultiChannelledLog) AddLogger(logger EventLogger) error

AddLogger adds a logger to this MultiChannelledLog

func (*MultiChannelledLog) Close added in v1.9.0

func (m *MultiChannelledLog) Close()

Close this MultiChannelledLog

func (*MultiChannelledLog) DelLogger added in v1.9.0

func (m *MultiChannelledLog) DelLogger(name string) bool

DelLogger removes a sub logger from this MultiChannelledLog NB: If you delete the last sublogger this logger will simply drop log events

func (*MultiChannelledLog) Flush added in v1.9.0

func (m *MultiChannelledLog) Flush()

Flush this ChannelledLog

func (*MultiChannelledLog) GetEventLogger added in v1.9.0

func (m *MultiChannelledLog) GetEventLogger(name string) EventLogger

GetEventLogger returns a sub logger from this MultiChannelledLog

func (*MultiChannelledLog) GetEventLoggerNames added in v1.9.0

func (m *MultiChannelledLog) GetEventLoggerNames() []string

GetEventLoggerNames returns a list of names

func (*MultiChannelledLog) GetLevel added in v1.9.0

func (m *MultiChannelledLog) GetLevel() Level

GetLevel gets the level of this MultiChannelledLog

func (*MultiChannelledLog) GetName added in v1.9.0

func (m *MultiChannelledLog) GetName() string

GetName gets the name of this MultiChannelledLog

func (*MultiChannelledLog) GetStacktraceLevel added in v1.9.0

func (m *MultiChannelledLog) GetStacktraceLevel() Level

GetStacktraceLevel gets the level of this MultiChannelledLog

func (*MultiChannelledLog) LogEvent added in v1.9.0

func (m *MultiChannelledLog) LogEvent(event *Event) error

LogEvent logs an event to this MultiChannelledLog

func (*MultiChannelledLog) ResetLevel added in v1.9.0

func (m *MultiChannelledLog) ResetLevel() Level

ResetLevel will reset the level of this MultiChannelledLog

func (*MultiChannelledLog) Start added in v1.9.0

func (m *MultiChannelledLog) Start()

Start processing the MultiChannelledLog

type MuxWriter

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

MuxWriter an *os.File writer with locker.

func (*MuxWriter) Close added in v1.9.0

func (mw *MuxWriter) Close() error

Close the internal writer

func (*MuxWriter) SetFd

func (mw *MuxWriter) SetFd(fd *os.File)

SetFd sets os.File in writer.

func (*MuxWriter) Write

func (mw *MuxWriter) Write(b []byte) (int, error)

Write writes to os.File.

type SMTPLogger added in v1.9.0

type SMTPLogger struct {
	WriterLogger
	Username           string   `json:"Username"`
	Password           string   `json:"password"`
	Host               string   `json:"host"`
	Subject            string   `json:"subject"`
	RecipientAddresses []string `json:"sendTos"`
	// contains filtered or unexported fields
}

SMTPLogger implements LoggerProvider and is used to send emails via given SMTP-server.

func (*SMTPLogger) Flush added in v1.9.0

func (log *SMTPLogger) Flush()

Flush when log should be flushed

func (*SMTPLogger) GetName added in v1.9.0

func (log *SMTPLogger) GetName() string

GetName returns the default name for this implementation

func (*SMTPLogger) Init added in v1.9.0

func (log *SMTPLogger) Init(jsonconfig string) error

Init smtp writer with json config. config like:

{
	"Username":"example@gmail.com",
	"password:"password",
	"host":"smtp.gmail.com:465",
	"subject":"email title",
	"sendTos":["email1","email2"],
	"level":LevelError
}

type WriterLogger added in v1.9.0

type WriterLogger struct {
	Level           Level  `json:"level"`
	StacktraceLevel Level  `json:"stacktraceLevel"`
	Flags           int    `json:"flags"`
	Prefix          string `json:"prefix"`
	Colorize        bool   `json:"colorize"`
	Expression      string `json:"expression"`
	// contains filtered or unexported fields
}

WriterLogger represent a basic logger for Gitea

func (*WriterLogger) Close added in v1.9.0

func (logger *WriterLogger) Close()

Close the base logger

func (*WriterLogger) GetLevel added in v1.9.0

func (logger *WriterLogger) GetLevel() Level

GetLevel returns the logging level for this logger

func (*WriterLogger) GetName added in v1.9.0

func (logger *WriterLogger) GetName() string

GetName returns empty for these provider loggers

func (*WriterLogger) GetStacktraceLevel added in v1.9.0

func (logger *WriterLogger) GetStacktraceLevel() Level

GetStacktraceLevel returns the stacktrace logging level for this logger

func (*WriterLogger) LogEvent added in v1.9.0

func (logger *WriterLogger) LogEvent(event *Event) error

LogEvent logs the event to the internal writer

func (*WriterLogger) Match added in v1.9.0

func (logger *WriterLogger) Match(event *Event) bool

Match checks if the given event matches the logger's regexp expression

func (*WriterLogger) NewWriterLogger added in v1.9.0

func (logger *WriterLogger) NewWriterLogger(out io.WriteCloser, level ...Level)

NewWriterLogger creates a new WriterLogger from the provided WriteCloser. Optionally the level can be changed at the same time.

Jump to

Keyboard shortcuts

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