logger

package
v3.35.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Copyright 2022 Molecula Corp. (DBA FeatureBase). SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	LevelPanic = iota
	LevelError
	LevelWarn
	LevelInfo
	LevelDebug
)
View Source
const RFC3339UsecTz0 = "2006-01-02T15:04:05.000000Z07:00"

Variables

View Source
var StderrLogger = NewStandardLogger(os.Stderr)

Functions

func LevelPrefix

func LevelPrefix(level int) string

func NewBufferLogger

func NewBufferLogger() *bufferLogger

NewBufferLogger returns a new instance of bufferLogger.

func NewStandardLogger

func NewStandardLogger(w io.Writer) *standardLogger

func NewVerboseLogger

func NewVerboseLogger(w io.Writer) *standardLogger

Types

type FileWriter

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

FileWriter that can also be reopened

func NewFileWriter

func NewFileWriter(name string) (*FileWriter, error)

NewFileWriter opens a file for appending and writing and can be reopened. it is a ReopenWriteCloser...

func NewFileWriterMode

func NewFileWriterMode(name string, mode os.FileMode) (*FileWriter, error)

NewFileWriterMode opens a Reopener file with a specific permission

func (*FileWriter) Close

func (f *FileWriter) Close() error

Close calls the underlyding File.Close()

func (*FileWriter) Fd

func (f *FileWriter) Fd() uintptr

Fd returns the file descriptor of the underlying file.

func (*FileWriter) Reopen

func (f *FileWriter) Reopen() error

Reopen the file

func (*FileWriter) Write

func (f *FileWriter) Write(p []byte) (int, error)

Write implements the stander io.Writer interface

type LogfLogger

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

LogfLogger is a test logger that wraps something that has a Logf interface and makes it act like our logger.

func NewLogfLogger

func NewLogfLogger(l Logfer) *LogfLogger

func (*LogfLogger) Debugf

func (ll *LogfLogger) Debugf(format string, v ...interface{})

func (*LogfLogger) Errorf

func (ll *LogfLogger) Errorf(format string, v ...interface{})

func (*LogfLogger) Infof

func (ll *LogfLogger) Infof(format string, v ...interface{})

func (*LogfLogger) Panicf

func (ll *LogfLogger) Panicf(format string, v ...interface{})

func (*LogfLogger) Printf

func (ll *LogfLogger) Printf(format string, v ...interface{})

func (*LogfLogger) Warnf

func (ll *LogfLogger) Warnf(format string, v ...interface{})

func (*LogfLogger) WithPrefix added in v3.32.0

func (ll *LogfLogger) WithPrefix(prefix string) Logger

WithPrefix does nothing for LogfLogger because I'm lazy.

type Logfer

type Logfer interface {
	Logf(format string, v ...interface{})
}

Logfer is a thing that has only a Logf() method, like for instance, testing.T or testing.B.

type Logger

type Logger interface {
	Printf(format string, v ...interface{}) // backward compatibility
	Debugf(format string, v ...interface{})
	Infof(format string, v ...interface{})
	Warnf(format string, v ...interface{})
	Errorf(format string, v ...interface{})
	Panicf(format string, v ...interface{})
	// WithPrefix returns a new Logger with the same configuration as
	// this one, but all logs will have the given prefix.
	WithPrefix(prefix string) Logger
}

Logger represents an interface for a shared logger.

var NopLogger Logger = &nopLogger{}

NopLogger represents a Logger that doesn't do anything.

Jump to

Keyboard shortcuts

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