# README

go-utils Logging

The go-utils Logging package provides handy methods for standardized logging.

Installation

To use the log package you must import the package.

import "github.com/eliona-smart-building-assistant/go-utils/log"

Optionally you can define an environment variable named LOG_LEVEL which sets the maximum level to be logged. Not defined the log packages takes the info log level as default.

export LOG_LEVEL=debug # This is optionally, default is info log level

Usage

After installation, you can use the logging like this:

import "github.com/eliona-smart-building-assistant/go-utils/log"

log.Info("start", "This could interest %d of %d people", 3, 4)
log.Debug("start", Usually nobody cares %s", "this")
log.Fatal("validate", "The house is on fire!") // exits with code 1

This produces the following output:

INFO    2022-05-03 15:34:41.770515      start   This could interest 3 of 4 people
DEBUG   2022-05-03 15:34:41.749597      start   Usually nobody cares this
FATAL   2022-05-03 15:34:41.770515      validate   The house is on fire!

# Functions

BufLimit returns bufLimit for standard Logger.
Debug calls Printf to print to the standard logger with the debug level.
Error calls Printf to print to the standard logger with the error level.
Fatal calls Printf to print to the standard logger with the debug level.
GetWriter returns an io.Writer implementation which log all data to the standard logger with log level and tag.
Info calls Printf to print to the standard logger with the info level.
Lev returns logging level for standard Logger.
New creates a new Logger.
Output writes the output for a logging event.
Print calls Output to print to the standard logger.
Printf calls Output to print to the standard logger.
Println calls Output to print to the standard logger.
SetBufLimit sets bufLimit for standard Logger.
SetLevel sets logging level for standard Logger.
SetOutput sets the output destination for the standard logger.
Timestamp calls Printf to print to the standard logger with the trace level and own timestamp.
Trace calls Printf to print to the standard logger with the trace level.
Warn calls Printf to print to the standard logger with the warning level.
Writer returns the output destination for the standard logger.

# Constants

DebugLevel level.
ErrorLevel level.
FatalLevel level.
InfoLevel level.
TraceLevel level.
WarnLevel level.

# Structs

A Logger represents an active logging object that generates lines of output to an io.Writer.

# Type aliases

Level type.