logger

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Provides a simple logging interface for console applications.

No log level configuration, log line support, file output, etc. is supported. But the logs automatically apply coloring to formatted elements in Printf() like statements, which is easy to use and looks nice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

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

A Logger is an object for logging to the console. An application would usually want to instanciate this once, using NewLogger(), and then use that instance throughout its application to log.

Logger implements Writer to allow attaching it to other logging modules' outputs.

func NewLogger

func NewLogger() *Logger

Create a new Logger.

func (*Logger) Error

func (l *Logger) Error(f string, a ...interface{})

Logs with Error severity.

Output still goes to stdout, but there is a red "[ERROR]" in the output.

func (*Logger) Info

func (l *Logger) Info(f string, a ...interface{})

Logs with Info severity.

func (*Logger) Log

func (l *Logger) Log(prefix string, f string, mid string, a ...interface{})

Main entry point for the Logger.

This is the function that does the heavy lifting. It outputs lines as follows to the standard output:

prefix " [" timestamp "] " mid fmt

where fmt is the output of Sprint(f, a...), with color codes injected around the verbs.

func (*Logger) Write

func (l *Logger) Write(p []byte) (n int, err error)

Implements Writer

Jump to

Keyboard shortcuts

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