Categorygithub.com/phogolabs/log
modulepackage
0.0.0-20230111045248-dad4d3c50e0f
Repository: https://github.com/phogolabs/log.git
Documentation: pkg.go.dev

# README

LOG

Documentation License Build Status Coverage Go Report Card

A simple logger for Golang

Installation

$ go get -u github.com/phogolabs/log

Getting started

import (
  "github.com/phogolabs/log"
  "github.com/phogolabs/log/console"
)

log.SetHandler(console.New(os.Stdout))

logger := log.WithFields(log.F("app", "service-api"))
logger.Info("Hello")

Levels

LevelDescription
DEBUGInfo useful to developers for debugging the application not useful during operations.
INFONormal operational messages - may be harvested for reporting measuring throughput etc. - no action required.
NOTICENormal but significant condition. Events that are unusual but not error conditions - might be summarized in an email to developers or admins to spot potential problems - no immediate action required.
WARNWarning messages not an error but indication that an error will occur if action is not taken e.g. file system 85% full - each item must be resolved within a given time.
ERRORNon-urgent failures; these should be relayed to developers or admins; each item must be resolved within a given time.
PANIC"A ""panic"" condition usually affecting multiple apps/servers/sites. At this level it would usually notify all tech staff on call."
ALERT"Action must be taken immediately. Should be corrected immediately, therefore notify staff who can fix the problem. An example would be the loss of a primary ISP connection."
FATAL"Should be corrected immediately, but indicates failure in a primary system; an example is a loss of a backup ISP connection. (same as SYSLOG CRITICAL)"

Contributing

We are open for any contributions. Just fork the project.

# Packages

Code generated by counterfeiter.
No description provided by the author

# Functions

Alert logs an alert log entry.
Alertf logs an alert log entry with formatting.
Debug logs a debug entry.
Debugf logs a debug entry with formatting.
Error logs an error log entry.
Errorf logs an error log entry with formatting.
Fatal logs a fatal log entry.
Fatalf logs a fatal log entry with formatting.
GetContext returns the log Entry found in the context, or a new Default log Entry if none is found.
Info logs a normal.
Infof logs a normal.
New creates a new logger.
Notice logs a notice log entry.
Noticef logs a notice log entry with formatting.
Panic logs a panic log entry.
Panicf logs a panic log entry with formatting.
ParseLevel parses a level.
SetContext sets a log entry into the provided context.
SetDefaultFields sets the default fields.
SetExitFunc sets the exit function.
SetHandler sets the handler.
SetLevel sets the level handler.
Warn logs a warn log entry.
Warnf logs a warn log entry with formatting.
WithError add a minimal stack trace to the log Entry.
WithField returns a new log entry with the supplied field.
WithFields returns a new log entry with the supplied fields appended.

# Constants

Log levels.
Log levels.
Log levels.
Log levels.
Log levels.
Log levels.
Log levels.
Log levels.

# Variables

LoggerCtxKey is the context.Context key to store the request log entry.

# Structs

Config is logger's configuration.
DefaultHandler represents the default handler.
Entry
Entry defines a single log entry.
LevelHandler handles entries for given level.

# Interfaces

Handler handles an entry.
Logger of the log.

# Type aliases

CompositeHandler is a slice of handler.
ExitFunc is a function called on Panic or Fatal level.
Level of the log.
Map is a map.