Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ingest Manager] Use libbeat logger #19211

Merged
merged 25 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e475617
remove ecs
michalpristas Jun 15, 2020
3a28e49
logging to file
michalpristas Jun 15, 2020
bf8a710
libbeat logger
michalpristas Jun 16, 2020
8991adb
lint
michalpristas Jun 16, 2020
3f3765c
fmt
michalpristas Jun 16, 2020
8f5edba
Merge branch 'master' of github.com:elastic/beats into agent-liblog
michalpristas Jun 16, 2020
61e6425
removed vendors
michalpristas Jun 17, 2020
bcd3798
notice
michalpristas Jun 17, 2020
f3dc1c6
1on1 with logp
michalpristas Jun 18, 2020
ea1e7df
removed debug line
michalpristas Jun 18, 2020
2c97982
conflicts
michalpristas Jun 18, 2020
5ae83e4
lint
michalpristas Jun 18, 2020
8a12713
Merge branch 'master' into agent-liblog
michalpristas Jun 18, 2020
91a7227
mage fmt
michalpristas Jun 18, 2020
d31c3fa
Merge branch 'master' of github.com:elastic/beats into agent-liblog
michalpristas Jun 18, 2020
6191329
Merge branch 'master' of github.com:elastic/beats into agent-liblog
michalpristas Jun 25, 2020
95e8f7f
Merge branch 'master' of github.com:elastic/beats into agent-liblog
michalpristas Jun 26, 2020
e029071
mods updated
michalpristas Jun 26, 2020
8e821ac
condlicts
michalpristas Jun 29, 2020
9f6813c
urso figured out
michalpristas Jun 29, 2020
987a7de
Merge branch 'master' of github.com:elastic/beats into agent-liblog
michalpristas Jun 30, 2020
eb80aa6
conflicts
michalpristas Jun 30, 2020
6e14936
Merge branch 'master' of github.com:elastic/beats into agent-liblog
michalpristas Jun 30, 2020
e2dd4df
Merge branch 'master' of github.com:elastic/beats into agent-liblog
michalpristas Jul 1, 2020
2a31933
Merge branch 'master' of github.com:elastic/beats into agent-liblog
michalpristas Jul 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this on by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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