Documentation ¶
Index ¶
- Constants
- func Caller(depth int) gokitlog.Valuer
- func Close() error
- func IncDBCallCounter(ctx context.Context) context.Context
- func InitCounter(ctx context.Context) context.Context
- func InitstartTime(ctx context.Context, now time.Time) context.Context
- func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) error
- func RegisterContextualLogProvider(mw ContextualLogProviderFunc)
- func Reload() error
- func Stack(skip int) string
- func StackCaller(skip int) gokitlog.Valuer
- func TimeSinceStart(ctx context.Context, now time.Time) time.Duration
- func TotalDBCallCount(ctx context.Context) int64
- type ConcreteLogger
- func (cl *ConcreteLogger) Debug(msg string, args ...interface{})
- func (cl *ConcreteLogger) Error(msg string, args ...interface{})
- func (cl *ConcreteLogger) FromContext(ctx context.Context) Logger
- func (cl ConcreteLogger) GetLogger() gokitlog.Logger
- func (cl *ConcreteLogger) Info(msg string, args ...interface{})
- func (cl *ConcreteLogger) Log(ctx ...interface{}) error
- func (cl *ConcreteLogger) New(ctx ...interface{}) *ConcreteLogger
- func (cl *ConcreteLogger) Warn(msg string, args ...interface{})
- type ContextualLogProviderFunc
- type DisposableHandler
- type FileLogWriter
- func (w *FileLogWriter) Close() error
- func (w *FileLogWriter) DoRotate() error
- func (w *FileLogWriter) Flush()
- func (w *FileLogWriter) Init() error
- func (w *FileLogWriter) Log(keyvals ...interface{}) error
- func (w *FileLogWriter) Reload() error
- func (w *FileLogWriter) StartLogger() error
- func (w *FileLogWriter) Write(b []byte) (int, error)
- type Formatedlogger
- type Logger
- type Lvl
- type ReloadableHandler
- type SysLogHandler
Constants ¶
const ( // top 7 calls in the stack are within logger DefaultCallerDepth = 7 CallerContextKey = "caller" )
Variables ¶
This section is empty.
Functions ¶
func Caller ¶
Caller proxies go-kit/log Caller and returns a Valuer function that returns a file and line from a specified depth in the callstack
func IncDBCallCounter ¶
IncDBCallCounter increments the database counter on the context.
func InitCounter ¶
InitCounter creates a pointer on the context that can be incremented later
func InitstartTime ¶
InitCounter creates a pointer on the context that can be incremented later
func ReadLoggingConfig ¶
func RegisterContextualLogProvider ¶
func RegisterContextualLogProvider(mw ContextualLogProviderFunc)
RegisterContextualLogProvider registers a ContextualLogProviderFunc that will be used to provide context when Logger.FromContext is called.
func StackCaller ¶
StackCaller returns a go-kit Valuer function that returns the stack trace from the place it is called. Argument `skip` allows skipping top n lines from the stack.
func TimeSinceStart ¶
TimeSinceStart returns time spend since the request started in grafana
func TotalDBCallCount ¶
TotalDBCallCount returns the total number of requests for the context
Types ¶
type ConcreteLogger ¶
type ConcreteLogger struct { gokitlog.SwapLogger // contains filtered or unexported fields }
func New ¶
func New(ctx ...interface{}) *ConcreteLogger
New creates a new logger. First ctx argument is expected to be the name of the logger. Note: For a contextual logger, i.e. a logger with a shared name plus additional contextual information, you must use the Logger interface New method for it to work as expected. Example creating a shared logger:
requestLogger := log.New("request-logger")
Example creating a contextual logger:
contextualLogger := requestLogger.New("username", "user123")
func NewNopLogger ¶
func NewNopLogger() *ConcreteLogger
NewNopLogger returns a logger that doesn't do anything.
func WithPrefix ¶
func WithPrefix(ctxLogger *ConcreteLogger, ctx ...interface{}) *ConcreteLogger
WithPrefix adds context that will be added to the log message
func WithSuffix ¶
func WithSuffix(ctxLogger *ConcreteLogger, ctx ...interface{}) *ConcreteLogger
WithSuffix adds context that will be appended at the end of the log message
func (*ConcreteLogger) Debug ¶
func (cl *ConcreteLogger) Debug(msg string, args ...interface{})
func (*ConcreteLogger) Error ¶
func (cl *ConcreteLogger) Error(msg string, args ...interface{})
func (*ConcreteLogger) FromContext ¶
func (cl *ConcreteLogger) FromContext(ctx context.Context) Logger
func (ConcreteLogger) GetLogger ¶
func (cl ConcreteLogger) GetLogger() gokitlog.Logger
func (*ConcreteLogger) Info ¶
func (cl *ConcreteLogger) Info(msg string, args ...interface{})
func (*ConcreteLogger) Log ¶
func (cl *ConcreteLogger) Log(ctx ...interface{}) error
func (*ConcreteLogger) New ¶
func (cl *ConcreteLogger) New(ctx ...interface{}) *ConcreteLogger
func (*ConcreteLogger) Warn ¶
func (cl *ConcreteLogger) Warn(msg string, args ...interface{})
type ContextualLogProviderFunc ¶
ContextualLogProviderFunc contextual log provider function definition.
type DisposableHandler ¶
type DisposableHandler interface {
Close() error
}
type FileLogWriter ¶
type FileLogWriter struct { Format Formatedlogger Filename string Maxlines int // Rotate at size Maxsize int // Rotate daily Daily bool Maxdays int64 Rotate bool sync.Mutex // contains filtered or unexported fields }
FileLogWriter implements LoggerInterface. It writes messages by lines limit, file size limit, or time frequency.
func NewFileWriter ¶
func NewFileWriter() *FileLogWriter
create a FileLogWriter returning as LoggerInterface.
func (*FileLogWriter) Close ¶
func (w *FileLogWriter) Close() error
destroy file logger, close file writer.
func (*FileLogWriter) DoRotate ¶
func (w *FileLogWriter) DoRotate() error
DoRotate means it need to write file in new file. new file name like xx.log.2013-01-01.2
func (*FileLogWriter) Flush ¶
func (w *FileLogWriter) Flush()
flush file logger. there are no buffering messages in file logger in memory. flush file means sync file from disk.
func (*FileLogWriter) Init ¶
func (w *FileLogWriter) Init() error
func (*FileLogWriter) Log ¶
func (w *FileLogWriter) Log(keyvals ...interface{}) error
func (*FileLogWriter) StartLogger ¶
func (w *FileLogWriter) StartLogger() error
start file logger. create log file and set to locker-inside file writer.
type Logger ¶
type Logger interface { // New returns a new contextual Logger that has this logger's context plus the given context. New(ctx ...interface{}) *ConcreteLogger Log(keyvals ...interface{}) error // Debug logs a message with debug level and key/value pairs, if any. Debug(msg string, ctx ...interface{}) // Info logs a message with info level and key/value pairs, if any. Info(msg string, ctx ...interface{}) // Warn logs a message with warning level and key/value pairs, if any. Warn(msg string, ctx ...interface{}) // Error logs a message with error level and key/value pairs, if any. Error(msg string, ctx ...interface{}) // FromContext returns a new contextual Logger that has this logger's context plus the given context. FromContext(ctx context.Context) Logger }
type ReloadableHandler ¶
type ReloadableHandler interface {
Reload() error
}
type SysLogHandler ¶
type SysLogHandler struct { Network string Address string Facility string Tag string Format Formatedlogger // contains filtered or unexported fields }
func NewSyslog ¶
func NewSyslog(sec *ini.Section, format Formatedlogger) *SysLogHandler
func (*SysLogHandler) Close ¶
func (sw *SysLogHandler) Close() error
func (*SysLogHandler) Init ¶
func (sw *SysLogHandler) Init() error
func (*SysLogHandler) Log ¶
func (sw *SysLogHandler) Log(keyvals ...interface{}) error