logging

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

logging is a wrapper around rs/zerolog making it easier to create & manage

Index

Constants

View Source
const DefaultLevel = "info"

DefaultLevel is the default log level

Variables

View Source
var (
	// UnknownTypeCause represents an error when an unknown logger type is encountered
	UnknownTypeCause = errors.NewCause(errors.BadRequestCategory, "unknown_logger")

	// UnknownLevelCause represents an error when an unknown log level is provided
	UnknownLevelCause = errors.NewCause(errors.BadRequestCategory, "unknown_log_level")
)

Functions

func Levels

func Levels() []string

Levels returns a map of a level to string representation

func Logger

func Logger(loggerType, logLevel, instanceID string) (*zerolog.Logger, error)

Logger returns a logger that can be passed into cape components. The logger will either discard all logs or writes logs to stderr depending on environment variables.

func Types

func Types() map[Type]string

Types returns a map of a type to string representation

Types

type Type

type Type string

Type represents a type of logger

var (
	// PrettyType represents a logger that prints nicely to stdout
	PrettyType Type = "pretty"

	// PrettyNoColorType is same as PrettyType but with no color
	PrettyNoColorType Type = "pretty_no_color"

	// DiscardType represents a logger that does not log anything
	DiscardType Type = "discard"

	// JSONType represents a logger that emits logs as json to stderr
	JSONType Type = "json"
)

func ParseType

func ParseType(in string) (Type, error)

ParseType returns a Type for the given string or an error if the type is unrecognized.

func (Type) String

func (t Type) String() string

String returns the type in string form

Jump to

Keyboard shortcuts

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