log

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package log provides basic logging mechanism.

You can log into physical file, but log rotation is not implemented, see https://12factor.net/logs => Ideally write to /dev/stderr|stdout|null and use something like https://github.com/logrotate/logrotate or https://github.com/agnivade/funnel for log post processing (funnel supports multiple targets, storing into files with rotation and compression) so let's not reinvent the wheel here.. TODO: - Enrich logger with methods of std logger for use in third party libs that needs it - If you get really bored some day: -- implement rolling files with https://github.com/natefinch/lumberjack -- allow writing into multiple files with io.MultiWriter

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenFileHelper

func OpenFileHelper(name string) (*os.File, error)

OpenFileHelper tries to make or create file (including dirs) with proper flags for use in logger

func StaticHook

func StaticHook(name string, value interface{}) zerolog.HookFunc

StaticHook returns hook for logging static name, value pair to every probe (like hostname, PID, local IP and such..), basic types are cast to avoid reflection

func TimestampHook

func TimestampHook() zerolog.HookFunc

TimestampHook returns hook for logging UnixNano timestamp as float64

Types

type Logger

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

Logger represents wrapper for logging mechanism

func New

func New(fileName string, mask string, hooks ...zerolog.HookFunc) *Logger

New creates logger if opening log file fails, logger will fallback to stderr you might want to use a log router like https://github.com/agnivade/funnel to handle app log output

func (*Logger) Close

func (l *Logger) Close()

Close cleans up after logger

Jump to

Keyboard shortcuts

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