logmanager

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

README

Log Manager

Log manager plugin allows to view and modify log levels of loggers using REST API.

API

  • List all registered loggers:

    curl -X GET http://<host>:<port>/log/list

  • Set log level for a registered logger: curl -X PUT http://<host>:<port>/log/<logger-name>/<log-level>

    <log-level> is one of debug,info,warning,error,fatal,panic

<host> and <port> are determined by configuration of rest.Plugin.

Config file

  • Logger config file is composed of two parts: the default level applied for all plugins, and a map where every logger can have its own log level defined. See config file example to learn how to define it.

    Note: initial log level can be set using environmental variable INITIAL_LOGLVL. The variable replaces default-level from configuration file. However, loggers (partial definition) replace default value set by environmental variable for specific loggers defined.

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