Commit Graph

27 Commits

Author SHA1 Message Date
Sebastiaan van Stijn df650a1aeb
panic() instead of logrus.Fatal() in init funcs
Some packages were using `logrus.Fatal()` in init functions (which logs the error,
and (by default) calls `os.Exit(1)` after logging).

Given that logrus formatting and outputs have not yet been configured during the
initialization stage, it does not provide much benefits over a plain `panic()`.

This patch replaces some instances of `logrus.Fatal()` with `panic()`, which has
the added benefits of not introducing logrus as a dependency in some of these
packages, and also produces a stacktrace, which could help locating the problem
in the unlikely event an `init()` fails.

Before this change, an error would look like:

    $ dockerd
    FATA[0000] something bad happened

After this change, the same error looks like:

    $ dockerd
    panic: something bad happened

    goroutine 1 [running]:
      github.com/docker/docker/daemon/logger/awslogs.init.0()
        /go/src/github.com/docker/docker/daemon/logger/awslogs/cloudwatchlogs.go:128 +0x89

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-21 12:15:20 +02:00
Sebastiaan van Stijn 2e831c76c2
daemon/logger/gelf: remove uses of pkg/urlutil.IsTransportURL()
pkg/urlutil (despite its poorly chosen name) is not really intended as a generic
utility to handle URLs, and should only be used by the builder to handle (remote)
build contexts.

This patch:

- removes a redundant use of urlutil.IsTransportURL(); code further below already
  checked if the given scheme (protocol) was supported.
- renames some variables that collided with imported packages.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-04-11 17:42:41 +02:00
Jonas Heinrich 5c6b913ff1
logger/gelf: Skip empty lines to comply with spec
The [gelf payload specification](http://docs.graylog.org/en/2.4/pages/gelf.html#gelf-payload-specification)
demands that the field `short_message` *MUST* be set by the client library.
Since docker logging via the gelf driver sends messages line by line, it can happen that messages with an empty
`short_message` are passed on. This causes strict downstream processors (like graylog) to raise an exception.

The logger now skips messages with an empty line.

Resolves: #40232
See also: #37572

Signed-off-by: Jonas Heinrich <Jonas@JonasHeinrich.com>
2019-11-25 11:55:15 +01:00
Robin THONI bc709991b3 Use a regex to match labels
Signed-off-by: Robin THONI <robin@rthoni.com>
2019-01-16 22:17:16 +00:00
Daniel Nephin 4f0d95fa6e Add canonical import comment
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-02-05 16:51:57 -05:00
John Stephens 72e179aa04
Merge pull request #35073 from mle-ii/master
Add gelf log driver plugin to Windows build
2017-11-08 14:53:56 -08:00
Mike Estes 10b449b997 Add gelf log driver plugin to Windows build
Signed-off-by: Mike Estes <mle_ii@yahoo.com>
2017-10-03 12:42:54 -07:00
Ghislain Bourgeois e17f351114 Add TCP support for GELF log driver
Signed-off-by: Ghislain Bourgeois <ghislain.bourgeois@gmail.com>
2017-09-06 17:45:26 -04:00
Ghislain Bourgeois e21f7b6e76 Add support for TCP parameters
Signed-off-by: Ghislain Bourgeois <ghislain.bourgeois@gmail.com>
2017-09-06 15:55:58 -04:00
Ghislain Bourgeois b24c8e07f1 Update to latest go-gelf version and add tests
Signed-off-by: Ghislain Bourgeois <ghislain.bourgeois@gmail.com>
2017-09-06 15:55:58 -04:00
Derek McGowan 1009e6a40b
Update logrus to v1.0.1
Fixes case sensitivity issue

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-07-31 13:16:46 -07:00
Brian Goff 1325f667ee Merge pull request #27565 from rothrock/env-by-regex
[splunk] Use a regex to match environment variables
2017-03-31 10:46:48 -04:00
Brian Goff 3f4fccb65f Use sync.Pool for logger Messages
This reduces allocs and bytes used per log entry significantly as well
as some improvement to time per log operation.

Each log driver, however, must put messages back in the pool once they
are finished with the message.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-02-01 13:52:37 -05:00
Joseph Rothrock 9758a2a724 Use a regex to match environment variables #27565
Signed-off-by: Joseph Rothrock <rothrock@rothrock.org>
2017-01-19 15:30:11 -08:00
Yanqiang Miao 17ec911da7 Rename 'context' to 'loginfo' in the logger module
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

gofmt

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

update

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

remove 'api/types/container/config.go' from this PR

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

change 'LogInfo' to 'Info'

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

update

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
2016-12-29 19:13:44 +08:00
unclejack 3a42518042 daemon: return directly without ifs where possible
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
2016-12-14 22:36:58 +02:00
Yanqiang Miao 52fd6e4664 Optimize the function 'Context.Name()' and replace 'Context.ContainerName' that need to remove slash with 'Context.Name()'.
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

update

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

update

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
2016-11-24 09:24:29 +08:00
Vincent Demeester f900e1cf47
Standardize default logging tag value
Use the same default tag value for all loggers that support tags.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2016-06-04 12:38:12 +02:00
Yong Tang a20b02b915 Remove deprecated driver specific log tags
Since 1.9, driver specific log tag options
`syslog-tag`
`gelf-tag`
`fluentd-tag`
have been deprecated in favor of the generic tag
option which is standard across different logging
drivers.

This fix removed the deprecated driver specific
log tag options of `syslog-tag`, `gelf-tag`,
`fluentd-tag` for 1.12 and updated the docs.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-05-10 07:43:44 -07:00
Daniel Dao bd94baa353 add gelf option to customize compression type and level
this allows user to choose the compression type (i.e. gzip/zlib/none) using
--log-opt=gelf-compression-type=none or the compression level (-1..9) using
--log-opt=gelf-compression-level=0 for gelf driver.

Signed-off-by: Daniel Dao <dqminh@cloudflare.com>
2016-03-15 11:06:06 +00:00
Marius Sturm a31435c8a2 dont trim gelf log message
Signed-off-by: Marius Sturm <marius@graylog.com>
2015-12-11 10:28:24 +01:00
Daniel Dao 5794a0190d add labels/env log option for gelf
this allows gelf logger to collect extra metadata from containers with
`--log-opt labels=label1,label2 --log-opt env=env1,env2`

Additional log field will be prefixed with `_` as per gelf protocol
https://www.graylog.org/resources/gelf/

Signed-off-by: Daniel Dao <dqminh@cloudflare.com>
2015-10-12 21:12:46 +02:00
Antonio Murdaca e3c472426f daemon: logger: error out on daemon start if invalid logger address
If an invalid logger address is provided on daemon start it will
silently fail. As syslog driver is doing, this check should be done on
daemon start and prevent it from starting even in other drivers.
This patch also adds integration tests for this behavior.

Signed-off-by: Antonio Murdaca <runcom@linux.com>
2015-09-20 16:20:25 +02:00
Philip Monroe 3be7146e14 log driver - add ability to interpolate container context into the log tag field
Signed-off-by: Philip Monroe <phil@philmonroe.com>
2015-09-16 15:19:28 -07:00
Morgan Bauer ccbe539e86
golint fixes for daemon/logger/*
- downcase and privatize exported variables that were unused
 - make accurate an error message
 - added package comments
 - remove unused var ReadLogsNotSupported
 - enable linter
 - some spelling corrections

Signed-off-by: Morgan Bauer <mbauer@us.ibm.com>
2015-07-29 13:09:39 -07:00
wlan0 9b782d3af3 add support for maximum log size, and max number of log files
Signed-off-by: wlan0 <sidharthamn@gmail.com>
2015-07-02 06:26:06 -07:00
Marius Sturm 96d06e106f add UDP GELF logging-driver
allows to send container logs to Graylog or Logstash.

Signed-off-by: Marius Sturm <marius@graylog.com>
2015-06-10 20:21:50 +02:00