logger

package
v0.0.0-...-9f3e423 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: Apache-2.0 Imports: 8 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/edgexfoundry/export-go/pkg/clients/logging"

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

Overview

******************************************************************************

  • Copyright 2017 Dell Inc. *
  • Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software distributed under the License
  • is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  • or implied. See the License for the specific language governing permissions and limitations under
  • the License. ******************************************************************************

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, labels ...string) error

Log a DEBUG level message

func (EdgeXLogger) Error

func (lc EdgeXLogger) Error(msg string, labels ...string) error

Log an ERROR level message

func (EdgeXLogger) Info

func (lc EdgeXLogger) Info(msg string, labels ...string) error

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, labels ...string) error

Log a TRACE level message

func (EdgeXLogger) Warn

func (lc EdgeXLogger) Warn(msg string, labels ...string) error

Log a WARN level message

type LoggingClient

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

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, labels ...string) error

func (MockLogger) Error

func (lc MockLogger) Error(msg string, labels ...string) error

func (MockLogger) Info

func (lc MockLogger) Info(msg string, labels ...string) error

func (MockLogger) SetLogLevel

func (lc MockLogger) SetLogLevel(loglevel string) error

func (MockLogger) Trace

func (lc MockLogger) Trace(msg string, labels ...string) error

func (MockLogger) Warn

func (lc MockLogger) Warn(msg string, labels ...string) error

Jump to

Keyboard shortcuts

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