logmanager

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2020 License: Apache-2.0 Imports: 15 Imported by: 8

Documentation

Overview

Package logmanager implements the log manager that allows users to set log levels at run-time via a REST API.

Index

Constants

View Source
const (
	HookSysLog   = "syslog"
	HookLogStash = "logstash"
	HookFluent   = "fluent"
)

list of supported hook services to send errors to remote syslog server

Variables

View Source
var DefaultPlugin = *NewPlugin()

DefaultPlugin is a default instance of Plugin.

Functions

This section is empty.

Types

type Config

type Config struct {
	DefaultLevel string                `json:"default-level"`
	Loggers      []LoggerConfig        `json:"loggers"`
	Hooks        map[string]HookConfig `json:"hooks"`
}

Config is a binding that supports to define default log levels for multiple loggers

func NewConf

func NewConf() *Config

NewConf creates default configuration with InfoLevel & empty loggers. Suitable also for usage in flavor to programmatically specify default behavior.

type Deps

type Deps struct {
	infra.PluginDeps
	ServiceLabel servicelabel.ReaderAPI
	LogRegistry  logging.Registry
	HTTP         rest.HTTPHandlers
}

Deps groups dependencies injected into the plugin so that they are logically separated from other plugin fields.

type HookConfig

type HookConfig struct {
	Protocol string
	Address  string
	Port     int
	Levels   []string
}

HookConfig contains configuration of hook services

type LoggerConfig

type LoggerConfig struct {
	Name  string
	Level string //debug, info, warn, error, fatal, panic
}

LoggerConfig is configuration of a particular logger. Currently we support only logger level.

type LoggerData

type LoggerData struct {
	Logger string `json:"logger"`
	Level  string `json:"level"`
}

LoggerData encapsulates parameters of a logger represented as strings.

type Option

type Option func(*Plugin)

Option is a function that can be used in NewPlugin to customize Plugin.

func UseConf

func UseConf(conf Config) Option

UseConf returns Option which injects a particular configuration.

func UseDeps

func UseDeps(cb func(*Deps)) Option

UseDeps returns Option that can inject custom dependencies.

type Plugin

type Plugin struct {
	Deps

	*Config
}

Plugin allows to manage log levels of the loggers.

func NewPlugin

func NewPlugin(opts ...Option) *Plugin

NewPlugin creates a new Plugin with the provided Options.

func (*Plugin) AfterInit

func (p *Plugin) AfterInit() error

AfterInit is called at plugin initialization. It register the following handlers:

  • List all registered loggers: > curl -X GET http://localhost:<port>/log/list
  • Set log level for a registered logger: > curl -X PUT http://localhost:<port>/log/<logger-name>/<log-level>

func (*Plugin) Close

func (p *Plugin) Close() error

Close is called at plugin cleanup phase.

func (*Plugin) Init

func (p *Plugin) Init() error

Init does nothing

Jump to

Keyboard shortcuts

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