logmanager

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

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 added in v1.5.0

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 added in v1.0.4

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 added in v1.5.0

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

HookConfig contains configuration of hook services

type LoggerConfig added in v1.5.0

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 added in v1.5.0

type Option func(*Plugin)

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

func UseConf added in v1.5.0

func UseConf(conf Config) Option

UseConf returns Option which injects a particular configuration.

func UseDeps added in v1.5.0

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 added in v1.5.0

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