logger

package
v0.0.0-...-7b61fee Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

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 communicate with the EdgeX support-logging microservice (regardless of underlying implemenation type) by sending REST requests to the service's API endpoints.

How To Use

To use the support-logging client package you first need to import the library into your project:

import "github.com/Circutor/edgex/pkg/clients/logger"

To send a log message to the centralized logging service, you first need to get a LoggingClient and then you can send logging messages into the service (indicating the level with the various log function call.

  logTarget := setLoggingTarget(*configuration)
	loggingClient = logger.NewClient(internal.CoreDataServiceKey, configuration.EnableRemoteLogging, logTarget)

  loggingClient.Info(consulMsg)
	loggingClient.Info(fmt.Sprintf("Starting %s %s ", internal.CoreDataServiceKey, edgex.Version))

Log messages can be logged as Info, Error, Debug, or Warn.

Documentation

Index

Constants

View Source
const (
	TraceLog = "TRACE"
	DebugLog = "DEBUG"
	InfoLog  = "INFO"
	WarnLog  = "WARN"
	ErrorLog = "ERROR"
)

These constants identify the log levels in order of increasing severity.

Variables

Functions

func IsValidLogLevel

func IsValidLogLevel(l string) bool

IsValidLogLevel checks if is a valid log level

Types

type EdgeXLogger

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

func (EdgeXLogger) Debug

func (lc EdgeXLogger) Debug(msg string, args ...interface{})

Log a DEBUG level message

func (EdgeXLogger) Error

func (lc EdgeXLogger) Error(msg string, args ...interface{})

Log an ERROR level message

func (EdgeXLogger) Info

func (lc EdgeXLogger) Info(msg string, args ...interface{})

Log an INFO level message

func (EdgeXLogger) SetLogLevel

func (lc EdgeXLogger) SetLogLevel(logLevel string) error

SetLogLevel sets minimum severity log level

func (EdgeXLogger) Trace

func (lc EdgeXLogger) Trace(msg string, args ...interface{})

Log a TRACE level message

func (EdgeXLogger) Warn

func (lc EdgeXLogger) Warn(msg string, args ...interface{})

Log a WARN level message

type LoggingClient

type LoggingClient interface {
	SetLogLevel(logLevel string) error
	Debug(msg string, args ...interface{})
	Error(msg string, args ...interface{})
	Info(msg string, args ...interface{})
	Trace(msg string, args ...interface{})
	Warn(msg string, args ...interface{})
}

func NewClient

func NewClient(owningServiceName string, isRemote bool, logTarget string, logLevel string) LoggingClient

Create a new logging client for the owning service

func NewMockClient

func NewMockClient() LoggingClient

type MockLogger

type MockLogger struct {
}

func (MockLogger) Debug

func (lc MockLogger) Debug(msg string, args ...interface{})

func (MockLogger) Error

func (lc MockLogger) Error(msg string, args ...interface{})

func (MockLogger) Info

func (lc MockLogger) Info(msg string, args ...interface{})

func (MockLogger) SetLogLevel

func (lc MockLogger) SetLogLevel(loglevel string) error

func (MockLogger) Trace

func (lc MockLogger) Trace(msg string, args ...interface{})

func (MockLogger) Warn

func (lc MockLogger) Warn(msg string, args ...interface{})

Jump to

Keyboard shortcuts

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