logger

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2021 License: MIT Imports: 6 Imported by: 52

Documentation

Overview

The oryx logger package provides connection-oriented log service.

logger.I(ctx, ...)
logger.T(ctx, ...)
logger.W(ctx, ...)
logger.E(ctx, ...)

Or use format:

logger.If(ctx, format, ...)
logger.Tf(ctx, format, ...)
logger.Wf(ctx, format, ...)
logger.Ef(ctx, format, ...)

@remark the Context is optional thus can be nil. @remark From 1.7+, the ctx could be context.Context, wrap by logger.WithContext,

please read ExampleLogger_ContextGO17().

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AliasContext added in v0.0.2

func AliasContext(parent context.Context, source context.Context) context.Context

Create context with value from parent, copy the cid from source context. @remark Create new cid if source has no cid represent.

func Close

func Close() (err error)

The interface io.Closer Cleanup the logger, discard any log util switch to fresh writer.

func E

func E(ctx Context, a ...interface{})

Alias for Error level println.

func Ef

func Ef(ctx Context, format string, a ...interface{})

Printf for Error level log.

func I

func I(ctx Context, a ...interface{})

Alias for Info level println.

func If

func If(ctx Context, format string, a ...interface{})

Printf for Info level log.

func Switch

func Switch(w io.Writer) io.Writer

Switch the underlayer io. @remark user must close previous io for logger never close it.

func T

func T(ctx Context, a ...interface{})

Alias for Trace level println.

func Tf

func Tf(ctx Context, format string, a ...interface{})

Printf for Trace level log.

func W

func W(ctx Context, a ...interface{})

Alias for Warn level println.

func Wf

func Wf(ctx Context, format string, a ...interface{})

Printf for Warn level log.

func WithContext

func WithContext(ctx context.Context) context.Context

Create context with value.

Types

type Context

type Context interface{}

The context for current goroutine. It maybe a cidContext or context.Context from GO1.7. @remark Use logger.WithContext(ctx) to wrap the context.

type Logger

type Logger interface {
	// Println for logger plus,
	// @param ctx the connection-oriented context,
	// 	or context.Context from GO1.7, or nil to ignore.
	Println(ctx Context, a ...interface{})
	Printf(ctx Context, format string, a ...interface{})
}

The logger for oryx.

var Error Logger

Error, the error level, fatal error things, ot Stdout.

var Info Logger

Info, the verbose info level, very detail log, the lowest level, to discard.

var Trace Logger

Trace, the trace level, something important, the default log level, to stdout.

var Warn Logger

Warn, the warning level, dangerous information, to Stdout.

func NewLoggerPlus

func NewLoggerPlus(l *log.Logger) Logger

Jump to

Keyboard shortcuts

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