control

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package control implements necessary functionality for runtime level toggling. A control file is used as level configuration. The file content is memory mapped in the process to do real time lookup when a log messages is created.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultControlPath is where the default log control instance will store its control file
	DefaultControlPath string

	// FATAL, ERROR, WARNING, INFO, DEBUG
	DefaultLevelString = fmt.Sprintf(" %3s %3s %3s %3s %3s", "ON", "ON", "ON", "ON", "OFF")
)

Functions

func ApplicationAndComponentToKey

func ApplicationAndComponentToKey(application, component string) string

ApplicationAndComponentToKey builds the lookup key format used by S

Types

type ControlLine

type ControlLine struct {
	Application string
	Component   string
	Ptr         ControlPtr
}

type ControlPtr

type ControlPtr []byte

func (ControlPtr) ShouldLog

func (p ControlPtr) ShouldLog(level Level) bool

type Level

type Level int

Level is the type used to specify a log message level fatal, error, warning, info or debug

type LogControl

type LogControl struct {
	ControlPath string
	// contains filtered or unexported fields
}

func MaybeNewGlobalLogControl

func MaybeNewGlobalLogControl() *LogControl

MaybeNewGlobalLogControl returns the cached global LogControl instance. The LogControl instance is created on the first invocation of the function.

func NewLogControl

func NewLogControl(controlPath string) *LogControl

func (*LogControl) Lock

func (c *LogControl) Lock() (func() error, error)

func (*LogControl) OpenForUpdate

func (c *LogControl) OpenForUpdate() (*LogControlForUpdate, error)

func (*LogControl) ReadControlFile

func (c *LogControl) ReadControlFile() error

func (*LogControl) Register

func (c *LogControl) Register(application, component string) error

func (*LogControl) ShouldLog

func (c *LogControl) ShouldLog(key string, level Level) bool

type LogControlForUpdate

type LogControlForUpdate struct {
	*LogControl
	// contains filtered or unexported fields
}

func (*LogControlForUpdate) Close

func (c *LogControlForUpdate) Close() error

func (*LogControlForUpdate) Flush

func (c *LogControlForUpdate) Flush() error

func (*LogControlForUpdate) ParseControl

func (c *LogControlForUpdate) ParseControl() ([]*WritableControlLine, error)

type WritableControlLine

type WritableControlLine struct {
	*ControlLine
	Ptr WritableControlPtr
}

type WritableControlPtr

type WritableControlPtr ControlPtr

func (WritableControlPtr) Off

func (p WritableControlPtr) Off(level Level)

Off disables a log level

func (WritableControlPtr) On

func (p WritableControlPtr) On(level Level)

On enables a log level

func (WritableControlPtr) ShouldLog

func (p WritableControlPtr) ShouldLog(level Level) bool

ShouldLog is a proxy for (p ControlPtr) ShouldLog(Level)

Directories

Path Synopsis
Package mmap implements functionality for keeping a files data in memory.
Package mmap implements functionality for keeping a files data in memory.

Jump to

Keyboard shortcuts

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