log

package module
v0.0.0-...-6ed475a Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: MIT Imports: 4 Imported by: 0

README

loki-logger

A logger that writes Debug logs directly to loki, and logs the rest to stdout.

uses two env variables:

  • LOKI_CLIENT_PUSH_URL - full URL to the loki push endpoint
    • if this is not set, pushing to loki is disabled
  • LOKI_CLIENT_X_SCOPE_ORG_ID - (optional) X-Scope-OrgID to set for pushes to loki

Documentation

Overview

Package log is a convenience wrapper for logging messages of various levels

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = &Logger{debug: false}

DefaultLogger is the default logging implementation. It's used in all top level funcs inside the log package, and represents the equivalent of NewLogger(os.Stderr, os.Stderr)

Functions

func Debug

func Debug(msg string, v ...interface{})

Debug is a convenience function for DefaultLogger.Debug(...)

func Err

func Err(format string, v ...interface{})

Err is a convenience function for DefaultLogger.Err(...)

func Info

func Info(format string, v ...interface{})

Info is a convenience function for DefaultLogger.Info(...)

func Reinitialize

func Reinitialize()

Reinitialize reads LOKI_CLIENT_PUSH_URL and sets up the loki client

func Warn

func Warn(format string, v ...interface{})

Warn is a convenience function for DefaultLogger.Warn(...)

Types

type Logger

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

Logger is the base logging struct from which all logging functionality stems

func NewLogger

func NewLogger(debug bool) *Logger

NewLogger creates a new logger bound to a stdout and stderr writer, which are most commonly os.Stdout and os.Stderr, respectively

func (*Logger) Debug

func (l *Logger) Debug(format string, v ...interface{})

Debug only sends directly to loki

func (*Logger) Err

func (l *Logger) Err(format string, v ...interface{})

Err prints an error message. It does not cause an exit.

func (*Logger) Info

func (l *Logger) Info(format string, v ...interface{})

Info prints a message

func (*Logger) SetDebug

func (l *Logger) SetDebug(debug bool)

SetDebug sets the internal debugging field on or off. This func is not concurrency safe.

func (*Logger) Warn

func (l *Logger) Warn(format string, v ...interface{})

Warn prints a warning message.

Jump to

Keyboard shortcuts

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