logger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: GPL-3.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultLogger

type DefaultLogger struct {
}

Default logging structure.

This is a simple implementation of the `ILogger` interface that simply redirects messages to `log.Printf`.

It is used in the same way as the main `Logger` implementation.

func NewDefaultLogger

func NewDefaultLogger() *DefaultLogger

Create a new default logger.

func (*DefaultLogger) Debug

func (l *DefaultLogger) Debug(msg string, rest ...interface{})

Write a debug message to the log.

func (*DefaultLogger) Fatal

func (l *DefaultLogger) Fatal(msg string, rest ...interface{})

Write a fatal message to the log and then exit.

func (*DefaultLogger) Info

func (l *DefaultLogger) Info(msg string, rest ...interface{})

Write an information message to the log.

func (*DefaultLogger) SetDebug

func (l *DefaultLogger) SetDebug(junk bool)

Set debug mode.

func (*DefaultLogger) SetLogFile

func (l *DefaultLogger) SetLogFile(junk string)

Set the log file to use.

func (*DefaultLogger) Warn

func (l *DefaultLogger) Warn(msg string, rest ...interface{})

Write a warning message to the log.

type ILogger

type ILogger interface {
	SetDebug(bool)
	SetLogFile(string)
	Debug(string, ...interface{})
	Warn(string, ...interface{})
	Info(string, ...interface{})
	Fatal(string, ...interface{})
}

type Logger

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

Logging structure.

To use,

1) Create a logger:

lgr := logger.NewLogger("/path/to/log")

2) Do things with it:

lgr.Warn("Not enough coffee!")
lgr.Info("Water is heating up.")
// and so on.

If an empty string is passed to `NewLogger`, then the log facility will display messages on standard output.

func NewLogger

func NewLogger() *Logger

Create a new logger.

func NewLoggerWithFile

func NewLoggerWithFile(logfile string) *Logger

Create a new logger with the given log file.

func (*Logger) Debug

func (l *Logger) Debug(msg string, rest ...interface{})

Write a debug message to the log.

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, rest ...interface{})

Write a fatal message to the log and then exit.

func (*Logger) Info

func (l *Logger) Info(msg string, rest ...interface{})

Write an information message to the log.

func (*Logger) SetDebug

func (l *Logger) SetDebug(flag bool)

Set debug mode.

Debug mode is a production-friendly runtime mode that will print human-readable messages to standard output instead of the defined log file.

func (*Logger) SetLogFile

func (l *Logger) SetLogFile(file string)

Set the log file to use.

func (*Logger) Warn

func (l *Logger) Warn(msg string, rest ...interface{})

Write a warning message to the log.

type MockLogger

type MockLogger struct {
	Test      *testing.T
	LastFatal string
}

Mock logger for Go testing framework.

To use, be sure to set `Test` to your test's `testing.T` instance.

func NewMockLogger

func NewMockLogger(junk string) *MockLogger

Create a new mock logger.

func (*MockLogger) Debug

func (l *MockLogger) Debug(msg string, rest ...interface{})

Write a debug message to the log.

func (*MockLogger) Fatal

func (l *MockLogger) Fatal(msg string, rest ...interface{})

Write a fatal message to the log and then exit.

func (*MockLogger) Info

func (l *MockLogger) Info(msg string, rest ...interface{})

Write an information message to the log.

func (*MockLogger) SetDebug

func (l *MockLogger) SetDebug(junk bool)

Set debug mode.

func (*MockLogger) SetLogFile

func (l *MockLogger) SetLogFile(junk string)

Set the log file to use.

func (*MockLogger) Warn

func (l *MockLogger) Warn(msg string, rest ...interface{})

Write a warning message to the log.

Jump to

Keyboard shortcuts

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