logging

package
v0.3.14 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: Apache-2.0 Imports: 6 Imported by: 10

Documentation

Overview

Copyright 2023 The acquirecloud Authors

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.

Package logging contains an abstract logging interface and methods that may be used with any logging engine. So as logging is extensively used in any application, it may not be easy to switch from one logging solution to another. Another reason is the unified logging approach, which helps to interpret the logs from different applications in the same way.

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.

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

This section is empty.

Variables

This section is empty.

Functions

func SetConfig added in v0.0.2

func SetConfig(cfg Config)

SetConfig allows to overwrite the current logger settings

func SetLevel

func SetLevel(lvl Level)

SetLevel allows to set the logging level

Types

type Config added in v0.0.2

type Config struct {
	// NewLoggerF points to the function to construct new Logger
	NewLoggerF func(loggerName string) Logger
	// SetLevelF points to the function to set specific logger level
	SetLevelF func(lvl Level)
	// GetLevelF returns the current log level
	GetLevelF func() Level
}

Config struct allows to set the current logger settings

type Level

type Level int32

Level is one of ERROR, WARN, INFO, DEBUG, of TRACE

const (
	ERROR Level = iota
	WARN
	INFO
	DEBUG
	TRACE
)

func GetLevel added in v0.3.7

func GetLevel() Level

GetLevel returns the current log level

type Logger

type Logger interface {
	// Warnf is a function for printing Warn-level messages from the source code
	Warnf(format string, args ...interface{})
	// Infof is a function for printing Info-level messages from the source code
	Infof(format string, args ...interface{})
	// Debugf is a function for printing Debug-level messages from the source code
	Debugf(format string, args ...interface{})
	// Tracef is a function for pretty printing Trace-level messages from the source code
	Tracef(format string, args ...interface{})
	// Errorf is a function for pretty printing Error-level messages from the source code
	Errorf(format string, args ...interface{})
}

Logger interface exposes some methods for application logging

func NewLogger

func NewLogger(loggerName string) Logger

NewLogger returns the new instance of Logger for the caller name.

Jump to

Keyboard shortcuts

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