logger

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 6 Imported by: 0

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) Debugf added in v0.1.1

func (l *DefaultLogger) Debugf(format string, args ...interface{})

Write a debug message to the log.

func (*DefaultLogger) Error added in v0.3.0

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

Write an error message to the log.

func (*DefaultLogger) Errorf added in v0.1.1

func (l *DefaultLogger) Errorf(msg string, args ...interface{})

Write an error message to the log and then exit.

func (*DefaultLogger) Fatal

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

Write a fatal message to the log and then exit.

func (*DefaultLogger) Fatalf added in v0.1.1

func (l *DefaultLogger) Fatalf(msg string, args ...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) Infof added in v0.1.1

func (l *DefaultLogger) Infof(msg string, args ...interface{})

Write an information message to the log.

func (*DefaultLogger) Panicf added in v0.1.1

func (l *DefaultLogger) Panicf(msg string, args ...interface{})

Write a fatal message to the log and then exit.

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.

func (*DefaultLogger) Warnf added in v0.1.1

func (l *DefaultLogger) Warnf(msg string, args ...interface{})

Write a warning message to the log.

func (*DefaultLogger) WithFields added in v0.1.1

func (l *DefaultLogger) WithFields(_ Fields) ILogger

type Fields added in v0.1.1

type Fields map[string]interface{}

type ILogger

type ILogger interface {
	SetDebug(bool)
	SetLogFile(string)

	Debug(string, ...interface{})
	Error(string, ...interface{})
	Warn(string, ...interface{})
	Info(string, ...interface{})
	Fatal(string, ...interface{})

	Debugf(string, ...interface{})
	Warnf(string, ...interface{})
	Infof(string, ...interface{})
	Fatalf(string, ...interface{})
	Errorf(string, ...interface{})
	Panicf(string, ...interface{})

	WithFields(Fields) ILogger
}

type Logger

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

Logging structure.

To use,

1) Create a logger:

```go

lgr := logger.NewLogger()

```

2) Do things with it:

```go

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) Debugf added in v0.1.1

func (l *Logger) Debugf(format string, args ...interface{})

Compatibility method.

func (*Logger) Error added in v0.3.0

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

Write an error message to the log.

func (*Logger) Errorf added in v0.1.1

func (l *Logger) Errorf(format string, args ...interface{})

Compatibility method.

func (*Logger) Fatal

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

Write a fatal message to the log and then exit.

func (*Logger) Fatalf added in v0.1.1

func (l *Logger) Fatalf(format string, args ...interface{})

Compatibility method.

func (*Logger) Info

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

Write an information message to the log.

func (*Logger) Infof added in v0.1.1

func (l *Logger) Infof(format string, args ...interface{})

Compatibility method.

func (*Logger) Panicf added in v0.1.1

func (l *Logger) Panicf(format string, args ...interface{})

Compatibility method.

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.

func (*Logger) Warnf added in v0.1.1

func (l *Logger) Warnf(format string, args ...interface{})

Compatibility method.

func (*Logger) WithFields added in v0.1.1

func (l *Logger) WithFields(fields Fields) ILogger

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(_ 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) Debugf added in v0.1.1

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

Write a debug message to the log.

func (*MockLogger) Error added in v0.3.0

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

Write an error message to the log.

func (*MockLogger) Errorf added in v0.1.1

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

Write a fatal message to the log and then exit.

func (*MockLogger) Fatal

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

Write a fatal message to the log and then exit.

func (*MockLogger) Fatalf added in v0.1.1

func (l *MockLogger) Fatalf(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) Infof added in v0.1.1

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

Write an information message to the log.

func (*MockLogger) Panicf added in v0.1.1

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

Write a fatal message to the log and then exit.

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.

func (*MockLogger) Warnf added in v0.1.1

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

Write a warning message to the log.

func (*MockLogger) WithFields added in v0.1.1

func (l *MockLogger) WithFields(_ Fields) ILogger

Jump to

Keyboard shortcuts

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