log

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: MPL-2.0-no-copyleft-exception Imports: 15 Imported by: 6

Documentation

Overview

Package log is a singleton package for logging either remotely or locally. If provided a host, it will connect to a service utilizing the syslogsvc protocol for tinyCI, and will alloow it to send log transmissions there.

Index

Constants

View Source
const (
	// LevelDebug is the debug loglevel
	LevelDebug = "DEBUG"
	// LevelError is the error loglevel
	LevelError = "ERROR"
	// LevelInfo is the info loglevel
	LevelInfo = "INFO"
)

Variables

This section is empty.

Functions

func ConfigureRemote

func ConfigureRemote(addr string, cert *transport.Cert, trace bool) error

ConfigureRemote configures the remote endpoint with a provided URL.

Types

type Client

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

Client is a small wrapper around the GRPC client that includes tracing data.

var (
	// RemoteClient is the swagger-based syslogsvc client.
	RemoteClient *Client
)

func (*Client) Close

func (c *Client) Close() error

Close closes the client's tracing functionality

type FieldMap

type FieldMap map[string]string

FieldMap is just a type alias for map[string]string to keep me from breaking my fingers.

func (FieldMap) ToFields

func (f FieldMap) ToFields() *Fields

ToFields converts a FieldMap to a *Fields

type Fields

type Fields _struct.Struct

Fields is just shorthand for some protobuf stuff.

func NewFields

func NewFields() *Fields

NewFields creates a compatible *Fields

func (*Fields) ToLogrus

func (f *Fields) ToLogrus() map[string]interface{}

ToLogrus just casts stuff to make logrus happy

type SubLogger

type SubLogger struct {
	Service string
	Fields  *Fields
}

SubLogger is a handle to cached parameters for logging.

func New

func New() *SubLogger

New creates a new SubLogger which can be primed with cached values for each log entry.

func NewWithData

func NewWithData(svc string, params FieldMap) *SubLogger

NewWithData returns a SubLogger already primed with cached data.

func (*SubLogger) Debug

func (sub *SubLogger) Debug(ctx context.Context, msg interface{})

Debug prints a debug message

func (*SubLogger) Debugf

func (sub *SubLogger) Debugf(ctx context.Context, msg string, values ...interface{})

Debugf is the format-capable version of Debug

func (*SubLogger) Error

func (sub *SubLogger) Error(ctx context.Context, msg interface{})

Error prints an error message

func (*SubLogger) Errorf

func (sub *SubLogger) Errorf(ctx context.Context, msg string, values ...interface{})

Errorf is the format-capable version of Error

func (*SubLogger) Info

func (sub *SubLogger) Info(ctx context.Context, msg interface{})

Info prints an info message

func (*SubLogger) Infof

func (sub *SubLogger) Infof(ctx context.Context, msg string, values ...interface{})

Infof is the format-capable version of Info

func (*SubLogger) Log

func (sub *SubLogger) Log(ctx context.Context, level string, msg interface{}, localLog func(...interface{}))

Log logs a thing

func (*SubLogger) Logf

func (sub *SubLogger) Logf(ctx context.Context, level string, msg string, values []interface{}, localLog func(string, ...interface{}))

Logf logs a thing with formats!

func (*SubLogger) WithFields

func (sub *SubLogger) WithFields(params FieldMap) *SubLogger

WithFields is a SubLogger version of package-level WithFields. They call the same code.

func (*SubLogger) WithRequest

func (sub *SubLogger) WithRequest(req *http.Request) *SubLogger

WithRequest is a wrapper for WithFields() that handles *http.Request data.

func (*SubLogger) WithService

func (sub *SubLogger) WithService(svc string) *SubLogger

WithService is a SubLogger version of package-level WithService. They call the same code.

func (*SubLogger) WithUser

func (sub *SubLogger) WithUser(user *model.User) *SubLogger

WithUser includes user information

Jump to

Keyboard shortcuts

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