Skip to content

Commit

Permalink
[Ingest Manager] Use libbeat logger (#19211)
Browse files Browse the repository at this point in the history
[Ingest Manager] Use libbeat logger (#19211)
  • Loading branch information
michalpristas authored Jul 1, 2020
1 parent 0800ab1 commit 2a1b4f4
Show file tree
Hide file tree
Showing 41 changed files with 2,806 additions and 2,864 deletions.
3,369 changes: 652 additions & 2,717 deletions NOTICE.txt

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dev-tools/notice/overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
{"name": "github.com/chzyer/logex", "licenceType": "MIT"}
{"name": "github.com/munnerz/goautoneg", "licenceType": "BSD-3-Clause"}
{"name": "github.com/pelletier/go-buffruneio", "licenceType": "MIT"}
{"name": "github.com/urso/magetools", "licenceType": "Apache-2.0"}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ require (
github.com/shirou/gopsutil v2.19.11+incompatible
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.5
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.6.1
github.com/tsg/go-daemon v0.0.0-20200207173439-e704b93fd89b
github.com/tsg/gopacket v0.0.0-20200626092518-2ab8e397a786
github.com/urso/ecslog v0.0.1
github.com/vmware/govmomi v0.0.0-20170802214208-2cad15190b41
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c
github.com/yuin/gopher-lua v0.0.0-20170403160031-b402f3114ec7 // indirect
Expand Down
31 changes: 1 addition & 30 deletions go.sum

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion libbeat/common/file/rotator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package file

import (
"fmt"
"os"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -301,7 +302,7 @@ func (r *Rotator) openFile() error {

r.file, err = os.OpenFile(r.filename, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, r.permissions)
if err != nil {
return errors.Wrap(err, "failed to open new file")
return errors.Wrap(err, fmt.Sprintf("failed to open new file '%s'", r.filename))
}
if r.redirectStderr {
RedirectStandardError(r.file)
Expand Down
28 changes: 14 additions & 14 deletions libbeat/logp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ import (
// Config contains the configuration options for the logger. To create a Config
// from a common.Config use logp/config.Build.
type Config struct {
Beat string `config:",ignore"` // Name of the Beat (for default file name).
JSON bool `config:"json"` // Write logs as JSON.
Level Level `config:"level"` // Logging level (error, warning, info, debug).
Selectors []string `config:"selectors"` // Selectors for debug level logging.
ECSEnabled bool `config:"ecs"` // Adds minimal ECS information using ECS conformant keys to every log line
Beat string `config:",ignore"` // Name of the Beat (for default file name).
JSON bool `config:"json"` // Write logs as JSON.
Level Level `config:"level"` // Logging level (error, warning, info, debug).
Selectors []string `config:"selectors"` // Selectors for debug level logging.
ECSEnabled bool `config:"ecs" yaml:"ecs"` // Adds minimal ECS information using ECS conformant keys to every log line

toObserver bool
toIODiscard bool
ToStderr bool `config:"to_stderr"`
ToSyslog bool `config:"to_syslog"`
ToFiles bool `config:"to_files"`
ToEventLog bool `config:"to_eventlog"`
ToStderr bool `config:"to_stderr" yaml:"to_stderr"`
ToSyslog bool `config:"to_syslog" yaml:"to_syslog"`
ToFiles bool `config:"to_files" yaml:"to_files"`
ToEventLog bool `config:"to_eventlog" yaml:"to_eventlog"`

Files FileConfig `config:"files"`

Expand All @@ -46,14 +46,14 @@ type Config struct {

// FileConfig contains the configuration options for the file output.
type FileConfig struct {
Path string `config:"path"`
Name string `config:"name"`
MaxSize uint `config:"rotateeverybytes" validate:"min=1"`
MaxBackups uint `config:"keepfiles" validate:"max=1024"`
Path string `config:"path" yaml:"path"`
Name string `config:"name" yaml:"name"`
MaxSize uint `config:"rotateeverybytes" yaml:"rotateeverybytes" validate:"min=1"`
MaxBackups uint `config:"keepfiles" yaml:"keepfiles" validate:"max=1024"`
Permissions uint32 `config:"permissions"`
Interval time.Duration `config:"interval"`
RotateOnStartup bool `config:"rotateonstartup"`
RedirectStderr bool `config:"redirect_stderr"`
RedirectStderr bool `config:"redirect_stderr" yaml:"redirect_stderr"`
}

const defaultLevel = InfoLevel
Expand Down
20 changes: 20 additions & 0 deletions libbeat/logp/level.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,26 @@ func (l *Level) Unpack(str string) error {
return errors.Errorf("invalid level '%v'", str)
}

// MarshalYAML marshals level in a correct form
func (l Level) MarshalYAML() (interface{}, error) {
s, found := levelStrings[l]
if found {
return s, nil
}

return nil, errors.Errorf("invalid level '%d'", l)
}

// MarshalJSON marshals level in a correct form
func (l Level) MarshalJSON() ([]byte, error) {
s, found := levelStrings[l]
if found {
return []byte(s), nil
}

return nil, errors.Errorf("invalid level '%d'", l)
}

func (l Level) zapLevel() zapcore.Level {
z, found := zapLevels[l]
if found {
Expand Down
Loading

0 comments on commit 2a1b4f4

Please sign in to comment.