README
¶
README
This package contains the logging client written in the Go programming language. The logging client is used by Go services or other Go code to log messages to STDOUT.
How To Use
To use the logging client package you first need to import the library into your project:
import "github.com/edgexfoundry/go-mod-core-contracts/v3/clients/logging"
To send a log message to STDOUT, you first need to create a LoggingClient with desired Log Level and then you can send log messages (indicating the log level of the message using one of the various log function calls).
loggingClient = logger.NewClient(internal.CoreDataServiceKey,configuration.Writable.LogLevel)
loggingClient.Info("Something interesting")
loggingClient.Infof("Starting %s %s ", internal.CoreDataServiceKey, edgex.Version)
loggingClient.Errorf("Something bad happened: %s", err.Error())
Log messages can be logged as Info, Debug, Trace, Warn, or Error
Documentation
¶
Overview ¶
Package logger provides a client for integration with the support-logging service. The client can also be configured to write logs to a local file rather than sending them to a service.
Index ¶
- type LoggingClient
- type MockLogger
- func (lc MockLogger) Debug(_ string, _ ...interface{})
- func (lc MockLogger) Debugf(_ string, _ ...interface{})
- func (lc MockLogger) Error(_ string, _ ...interface{})
- func (lc MockLogger) Errorf(_ string, _ ...interface{})
- func (lc MockLogger) Info(_ string, _ ...interface{})
- func (lc MockLogger) Infof(_ string, _ ...interface{})
- func (lc MockLogger) LogLevel() string
- func (lc MockLogger) SetLogLevel(_ string) errors.EdgeX
- func (lc MockLogger) Trace(_ string, _ ...interface{})
- func (lc MockLogger) Tracef(_ string, _ ...interface{})
- func (lc MockLogger) Warn(_ string, _ ...interface{})
- func (lc MockLogger) Warnf(_ string, _ ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LoggingClient ¶
type LoggingClient interface { // SetLogLevel sets minimum severity log level. If a logging method is called with a lower level of severity than // what is set, it will result in no output. SetLogLevel(logLevel string) errors.EdgeX // LogLevel returns the current log level setting LogLevel() string // Debug logs a message at the DEBUG severity level Debug(msg string, args ...interface{}) // Error logs a message at the ERROR severity level Error(msg string, args ...interface{}) // Info logs a message at the INFO severity level Info(msg string, args ...interface{}) // Trace logs a message at the TRACE severity level Trace(msg string, args ...interface{}) // Warn logs a message at the WARN severity level Warn(msg string, args ...interface{}) // Debugf logs a formatted message at the DEBUG severity level Debugf(msg string, args ...interface{}) // Errorf logs a formatted message at the ERROR severity level Errorf(msg string, args ...interface{}) // Infof logs a formatted message at the INFO severity level Infof(msg string, args ...interface{}) // Tracef logs a formatted message at the TRACE severity level Tracef(msg string, args ...interface{}) // Warnf logs a formatted message at the WARN severity level Warnf(msg string, args ...interface{}) }
LoggingClient defines the interface for logging operations.
func NewClient ¶
func NewClient(owningServiceName string, logLevel string) LoggingClient
NewClient creates an instance of LoggingClient
func NewMockClient ¶
func NewMockClient() LoggingClient
NewMockClient creates a mock instance of LoggingClient
type MockLogger ¶
type MockLogger struct { }
MockLogger is a type that can be used for mocking the LoggingClient interface during unit tests
func (MockLogger) Debug ¶
func (lc MockLogger) Debug(_ string, _ ...interface{})
Debug simulates logging an entry at the DEBUG severity level
func (MockLogger) Debugf ¶
func (lc MockLogger) Debugf(_ string, _ ...interface{})
Debugf simulates logging an formatted message at the DEBUG severity level
func (MockLogger) Error ¶
func (lc MockLogger) Error(_ string, _ ...interface{})
Error simulates logging an entry at the ERROR severity level
func (MockLogger) Errorf ¶
func (lc MockLogger) Errorf(_ string, _ ...interface{})
Errorf simulates logging an formatted message at the ERROR severity level
func (MockLogger) Info ¶
func (lc MockLogger) Info(_ string, _ ...interface{})
Info simulates logging an entry at the INFO severity level
func (MockLogger) Infof ¶
func (lc MockLogger) Infof(_ string, _ ...interface{})
Infof simulates logging an formatted message at the INFO severity level
func (MockLogger) LogLevel ¶
func (lc MockLogger) LogLevel() string
LogLevel returns the current log level setting
func (MockLogger) SetLogLevel ¶
func (lc MockLogger) SetLogLevel(_ string) errors.EdgeX
SetLogLevel simulates setting a log severity level
func (MockLogger) Trace ¶
func (lc MockLogger) Trace(_ string, _ ...interface{})
Trace simulates logging an entry at the TRACE severity level
func (MockLogger) Tracef ¶
func (lc MockLogger) Tracef(_ string, _ ...interface{})
Tracef simulates logging an formatted message at the TRACE severity level
func (MockLogger) Warn ¶
func (lc MockLogger) Warn(_ string, _ ...interface{})
Warn simulates logging an entry at the WARN severity level
func (MockLogger) Warnf ¶
func (lc MockLogger) Warnf(_ string, _ ...interface{})
Warnf simulates logging an formatted message at the WARN severity level