log
Explore the following sections to learn more:
log
import "github.com/gemini-oss/rego/pkg/common/log"
pkg/common/log/log.go
Index
- Constants
- func LogLevel(level int, color bool) string
- type LogOption
- type Logger
- func NewLogger(prefix string, verbosity int, opts …LogOption) *Logger
- func (l *Logger) Close() error
- func (l *Logger) Debug(v …interface{})
- func (l *Logger) Debugf(format string, v …interface{})
- func (l *Logger) Delete() error
- func (l *Logger) Error(v …interface{})
- func (l *Logger) Errorf(format string, v …interface{})
- func (l *Logger) Fatal(v …interface{})
- func (l *Logger) Fatalf(format string, v …interface{})
- func (l *Logger) Info(v …interface{})
- func (l *Logger) Infof(format string, v …interface{})
- func (l *Logger) Panic(v …interface{})
- func (l *Logger) Panicf(format string, v …interface{})
- func (l *Logger) Print(v …interface{})
- func (l *Logger) Printf(format string, v …interface{})
- func (l *Logger) Println(v …interface{})
- func (l *Logger) SetNewFile(logFilePath string)
- func (l *Logger) SetOutput(output io.Writer)
- func (l *Logger) Trace(v …interface{})
- func (l *Logger) Tracef(format string, v …interface{})
- func (l *Logger) Warning(v …interface{})
- func (l *Logger) Warningf(format string, v …interface{})
Constants
const (
// Log level constants
TRACE = iota
DEBUG
INFO
WARNING
ERROR
FATAL
PANIC
// Color Escape Codes
Black = "\033[30m"
Red = "\033[31m"
Green = "\033[32m"
Yellow = "\033[33m"
Blue = "\033[34m"
Magenta = "\033[35m"
Cyan = "\033[36m"
White = "\033[37m"
Reset = "\033[0m"
// Formatting
Bold = "\033[1m"
Italic = "\033[3m"
Underline = "\033[4m"
)
func LogLevel
func LogLevel(level int, color bool) string
* @param {int} level - log level
- @param {bool} color - enable/disable colorized output
- @return {string} - string representation of log level
type LogOption
LogOption is a function that modifies a Logger
type LogOption func(*Logger)
func WithColor
func WithColor(enabled bool) LogOption
WithColor enables/disables colorized output
func WithFile
func WithFile(filepath string) LogOption
WithFile configures the logger to only output to file (no stdout)
func WithLogFile
func WithLogFile(filepath string) LogOption
WithLogFile configures the logger to output to a specific file and stdout
func WithRotatingFile
func WithRotatingFile(filepath string, maxSizeMB int64, maxBackups int, compress bool) LogOption
WithRotatingFile configures the logger with a rotating log file
func WithStdout
func WithStdout() LogOption
WithStdout configures the logger to only output to stdout
type Logger
type Logger struct {
Color bool // enable/disable colorized output
Verbosity int // log level {TRACE, DEBUG, INFO, WARNING, ERROR, FATAL, PANIC}
// contains filtered or unexported fields
}
func NewLogger
func NewLogger(prefix string, verbosity int, opts ...LogOption) *Logger
* # NewLogger
- - creates a new Logger with the specified prefix
func (*Logger) Close
func (l *Logger) Close() error
* # log.Close
- - closes the Logger’s file if it is a *os.File
func (*Logger) Debug
func (l *Logger) Debug(v ...interface{})
* # log.Debug
- - logs line at DEBUG level
func (*Logger) Debugf
func (l *Logger) Debugf(format string, v ...interface{})
* # log.Debugf
- - logs formatted message at DEBUG level
func (*Logger) Delete
func (l *Logger) Delete() error
* # log.Delete
- - Delete the Logger’s file if it is a *os.File
func (*Logger) Error
func (l *Logger) Error(v ...interface{})
* # log.Error
- - logs formatted message at ERROR level
func (*Logger) Errorf
func (l *Logger) Errorf(format string, v ...interface{})
* # log.Errorf
- - logs formatted message at ERROR level
func (*Logger) Fatal
func (l *Logger) Fatal(v ...interface{})
* # log.Fatal
- - logs line at FATAL level
func (*Logger) Fatalf
func (l *Logger) Fatalf(format string, v ...interface{})
* # log.Fatal
- - logs formatted message at FATAL level and then calls os.Exit(1)
func (*Logger) Info
func (l *Logger) Info(v ...interface{})
* # log.Info
- - logs line at INFO level
func (*Logger) Infof
func (l *Logger) Infof(format string, v ...interface{})
* # log.Infof
- - logs formatted message at INFO level
func (*Logger) Panic
func (l *Logger) Panic(v ...interface{})
* # log.Panic
- - logs line at PANIC level and then panics
func (*Logger) Panicf
func (l *Logger) Panicf(format string, v ...interface{})
* # log.Panicf
- - logs formatted message at PANIC level and then panics
func (*Logger) Print
func (l *Logger) Print(v ...interface{})
* # log.Print
- - logs line at INFO level
func (*Logger) Printf
func (l *Logger) Printf(format string, v ...interface{})
* # log.Printf
- - logs formatted message at INFO level
func (*Logger) Println
func (l *Logger) Println(v ...interface{})
* # log.Println
- - logs line at INFO level
func (*Logger) SetNewFile
func (l *Logger) SetNewFile(logFilePath string)
SetNewFile sets the output destination for the logger to a new file.
func (*Logger) SetOutput
func (l *Logger) SetOutput(output io.Writer)
SetOutput sets the output destination for the logger.
func (*Logger) Trace
func (l *Logger) Trace(v ...interface{})
* # log.Trace
- - logs line at TRACE level
func (*Logger) Tracef
func (l *Logger) Tracef(format string, v ...interface{})
* # log.Tracef
- - logs formatted message at TRACE level
func (*Logger) Warning
func (l *Logger) Warning(v ...interface{})
* # log.Warning
- - logs formatted message at WARNING level
func (*Logger) Warningf
func (l *Logger) Warningf(format string, v ...interface{})
* # log.Warningf
- - logs formatted message at WARNING level
Generated by gomarkdoc