maleozap

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Caller added in v0.3.1

type Caller struct {
	maleo.Caller
}

func (Caller) MarshalLogObject added in v0.3.1

func (ca Caller) MarshalLogObject(enc zapcore.ObjectEncoder) error

type DisabledField added in v0.1.1

type DisabledField uint8
const (
	DisableTime DisabledField = 1 << iota
	DisableCaller
	DisableTrace
	DisableService
	DisableKey
	DisableCode
	DisableContext
	DisableError

	DisableNothing DisabledField = 0
	DisableAll     DisabledField = ^DisableNothing
)

func (DisabledField) Has added in v0.1.1

func (d DisabledField) Has(flag DisabledField) bool

func (*DisabledField) Set added in v0.1.1

func (d *DisabledField) Set(flag DisabledField)

type Entry

type Entry struct {
	maleo.Entry
}

func (Entry) MarshalLogObject

func (e Entry) MarshalLogObject(enc zapcore.ObjectEncoder) error

type Error

type Error struct {
	maleo.Error
}

func (Error) MarshalLogObject

func (err Error) MarshalLogObject(enc zapcore.ObjectEncoder) error

type Logger

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

func New added in v0.1.1

func New(l *zap.Logger) *Logger
Example (Production)
package main

import (
	"go.uber.org/zap"

	"github.com/tigorlazuardi/maleo"
	"github.com/tigorlazuardi/maleo/maleozap"
)

func main() {
	logger, err := zap.NewProduction()
	if err != nil {
		panic(err)
	}
	mlog := maleozap.New(logger)
	maleo.Global().SetLogger(mlog)
}
Output:

func (*Logger) Log

func (l *Logger) Log(ctx context.Context, entry maleo.Entry)

func (*Logger) LogError

func (l *Logger) LogError(ctx context.Context, err maleo.Error)

func (*Logger) SetDisabledFieldFlag added in v0.1.1

func (l *Logger) SetDisabledFieldFlag(flag DisabledField)

SetDisabledFieldFlag sets the field from Maleo's Entry or Maleo's Error from being added to the zap log fields.

e.g. SetDisableField(maleozap.DisableTime | maleozap.DisableCaller) will prevent data of Error.Time() or Error.Caller() from being printed.

func (*Logger) SetTraceCapturer

func (l *Logger) SetTraceCapturer(capturer TraceCapturer)

type LoggerOption added in v0.1.1

type LoggerOption interface {
	Apply(*Logger)
}

func WithDisableFieldFlag added in v0.1.1

func WithDisableFieldFlag(fieldFlag DisabledField) LoggerOption

func WithTraceCapturer added in v0.1.1

func WithTraceCapturer(capturer TraceCapturer) LoggerOption

type LoggerOptionFunc added in v0.1.1

type LoggerOptionFunc func(*Logger)

func (LoggerOptionFunc) Apply added in v0.1.1

func (f LoggerOptionFunc) Apply(l *Logger)

type TraceCapturer

type TraceCapturer interface {
	CaptureTrace(ctx context.Context) []zap.Field
}

type TraceCapturerFunc

type TraceCapturerFunc func(ctx context.Context) []zap.Field

func (TraceCapturerFunc) CaptureTrace

func (f TraceCapturerFunc) CaptureTrace(ctx context.Context) []zap.Field

Jump to

Keyboard shortcuts

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