Commit Graph

33 Commits

Author SHA1 Message Date
Maksym Pavlenko
370be0c18f Move logrus setup code to log package
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-04-24 10:14:13 -07:00
Maksym Pavlenko
06e085c8b5 Add Fields type alias to log package
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-02-20 17:29:08 -08:00
Wei Fu
6de94a4cc1 log/logtest: add testcase as debug field
It is hard to tell where the `log_hook` log comes from, when we run test
parallelly. Add test name as field as debug purpose.

```
log_hook.go:47: time="2023-01-29T13:09:37.687070239+08:00" level=debug msg=fetch func=remotes.Fetch file="/home/fuwei/go/src/github.com/containerd/containerd/remotes/handlers.go:114" digest="sha256:ea362f368469f909a95f9a6e54ebe0121ce0a8e3c30583dd9c5fb35b14544dec" mediatype=application/vnd.docker.image.rootfs.diff.tar.gzip size=28566425 testcase=TestCRIImagePullTimeout/NoDataTransferred
```

REF: #8024

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-01-29 13:09:55 +08:00
Kazuyoshi Kato
791428005f Prevent a race condition in testHook
The logger could be called from multiple goroutines,
but t.Log() is not designed for.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-12-16 23:50:38 +00:00
Maksym Pavlenko
871b6b6a9f Use testify
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-04-01 18:17:58 -07:00
Derek McGowan
63b7e5771e
Merge pull request #5973 from Juneezee/deprecate-ioutil
refactor: move from io/ioutil to io and os package
2021-10-01 10:52:06 -07:00
Brian Goff
45c3453a7c Add open telemetry logging hook for logrus
This adds valuable logging data to the open telemetry traces.

When the trace is not recording we don't bother doing anything as it is
relatively expensive to convert logrus data to otel just due to the
nature of how logrus works.

The way this works is that we now set a context on the logrus.Entry that
gets passed around which the hook then uses to determine if there is an
active span to forward the logs to.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-09-21 21:19:28 +00:00
Eng Zer Jun
50da673592
refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-09-21 09:50:38 +08:00
Iceber Gu
bf9db47e8a
add caller info to the testHook
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2021-03-23 09:26:27 +08:00
Vlad Ungureanu
f12b68cc86 Allow configuration of different log formats: text, json
Signed-off-by: Vlad Ungureanu <vladu@palantir.com>
2020-12-04 13:12:41 -05:00
Sebastiaan van Stijn
f2edc6f164
vendor: update gotest.tools v3.0.2
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-28 17:47:20 +01:00
Lantao Liu
20e844a227 Use logrus trace support.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-10-24 20:12:19 -07:00
chentanjun
92a5b08a68 fix-grammar-mistake
Signed-off-by: chentanjun <2799194073@qq.com>
2019-08-28 16:10:08 +08:00
Derek McGowan
f63eab32e1
Add testing log hook to context
Allows log output to sent along with test output
for cleaner output and clearer ordering.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-07-16 10:31:43 -07:00
Sebastiaan van Stijn
da73b98b63
Set default log formatting to use RFC3339Nano with fixed width
This patch changes the logs format to use a fixed-width timestamp,
matching the format that's used in dockerd.

Before:

    $ containerd
    INFO[0000] starting containerd                           revision=a88b6319614de846458750ff882723479ca7b1a1 version=v1.1.0-202-ga88b6319
    INFO[0000] loading plugin "io.containerd.content.v1.content"...  type=io.containerd.content.v1
    INFO[0000] loading plugin "io.containerd.snapshotter.v1.btrfs"...  type=io.containerd.snapshotter.v1
    WARN[0000] failed to load plugin io.containerd.snapshotter.v1.btrfs  error="path /var/lib/containerd/io.containerd.snapshotter.v1.btrfs must be a btrfs filesystem to be used with the btrfs snapshotter"

After:

    $ containerd
    INFO[2018-07-24T08:11:07.397856489Z] starting containerd                           revision=c3195155cacb361cd3549c4d78901b20aa19579a version=v1.1.0-203-gc3195155
    INFO[2018-07-24T08:11:07.399264587Z] loading plugin "io.containerd.content.v1.content"...  type=io.containerd.content.v1
    INFO[2018-07-24T08:11:07.399343959Z] loading plugin "io.containerd.snapshotter.v1.btrfs"...  type=io.containerd.snapshotter.v1
    WARN[2018-07-24T08:11:07.399474423Z] failed to load plugin io.containerd.snapshotter.v1.btrfs  error="path /var/lib/containerd/io.containerd.snapshotter.v1.btrfs must be a btrfs filesystem to be used with the btrfs snapshotter"

Or, when running as child-process of dockerd:

Before:

    root@9637fcd85ea4:/go/src/github.com/docker/docker# dockerd --debug
    DEBU[2018-07-24T08:15:16.946312436Z] Listener created for HTTP on unix (/var/run/docker.sock)
    INFO[2018-07-24T08:15:16.947086499Z] libcontainerd: started new docker-containerd process  pid=231
    INFO[2018-07-24T08:15:16.947137166Z] parsed scheme: "unix"                         module=grpc
    INFO[2018-07-24T08:15:16.947235001Z] scheme "unix" not registered, fallback to default scheme  module=grpc
    INFO[2018-07-24T08:15:16.947463403Z] ccResolverWrapper: sending new addresses to cc: [{unix:///var/run/docker/containerd/docker-containerd.sock 0  <nil>}]  module=grpc
    INFO[2018-07-24T08:15:16.947505954Z] ClientConn switching balancer to "pick_first"  module=grpc
    INFO[2018-07-24T08:15:16.947717368Z] pickfirstBalancer: HandleSubConnStateChange: 0xc420507ab0, CONNECTING  module=grpc
    INFO[0000] starting containerd                           revision=d64c661f1d51c48782c9cec8fda7604785f93587 version=v1.1.1
    DEBU[0000] changing OOM score to -500
    INFO[0000] loading plugin "io.containerd.content.v1.content"...  type=io.containerd.content.v1
    INFO[0000] loading plugin "io.containerd.snapshotter.v1.btrfs"...  type=io.containerd.snapshotter.v1
    WARN[0000] failed to load plugin io.containerd.snapshotter.v1.btrfs  error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs must be a btrfs filesystem to be used with the btrfs snapshotter"

After:

    DEBU[2018-07-24T08:21:33.441741970Z] Listener created for HTTP on unix (/var/run/docker.sock)
    INFO[2018-07-24T08:21:33.442428017Z] libcontainerd: started new docker-containerd process  pid=232
    INFO[2018-07-24T08:21:33.442510827Z] parsed scheme: "unix"                         module=grpc
    INFO[2018-07-24T08:21:33.442598812Z] scheme "unix" not registered, fallback to default scheme  module=grpc
    INFO[2018-07-24T08:21:33.442681006Z] ccResolverWrapper: sending new addresses to cc: [{unix:///var/run/docker/containerd/docker-containerd.sock 0  <nil>}]  module=grpc
    INFO[2018-07-24T08:21:33.442770353Z] ClientConn switching balancer to "pick_first"  module=grpc
    INFO[2018-07-24T08:21:33.442871502Z] pickfirstBalancer: HandleSubConnStateChange: 0xc42018bc30, CONNECTING  module=grpc
    INFO[2018-07-24T08:21:33.457963804Z] starting containerd                           revision=597dd082e37f8bc6b6265ca05839d7a300861911 version=597dd082
    DEBU[2018-07-24T08:21:33.458113301Z] changing OOM score to -500
    INFO[2018-07-24T08:21:33.458474842Z] loading plugin "io.containerd.content.v1.content"...  type=io.containerd.content.v1
    INFO[2018-07-24T08:21:33.458911054Z] loading plugin "io.containerd.snapshotter.v1.btrfs"...  type=io.containerd.snapshotter.v1
    WARN[2018-07-24T08:21:33.459366268Z] failed to load plugin io.containerd.snapshotter.v1.btrfs  error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs must be a btrfs filesystem to be used with the btrfs snapshotter"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-07-24 10:23:38 +02:00
Vincent Demeester
832b05ae67
Update tests to use gotest.tools angel
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-06-08 21:02:01 +02:00
Kunal Kushwaha
b12c3215a0 Licence header added
Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2018-02-19 10:32:26 +09:00
Daniel Nephin
37aa41b164 Cleanup after migration
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2018-02-12 12:26:26 -05:00
Daniel Nephin
ef48a0268e Migrate to gotestyourself/assert
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2018-02-12 12:26:26 -05:00
Lantao Liu
f2c585a59a Fix trace level support.
Signed-off-by: Lantao Liu <lantaol@google.com>
2018-02-07 01:14:05 +00:00
Lantao Liu
050ff32dea Support trace level.
Signed-off-by: Lantao Liu <lantaol@google.com>
2018-02-06 02:30:05 +00:00
Michael Crosby
db78450e8b Remove grpclogger from log package
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-02-01 17:20:49 -05:00
Stephen J Day
5cab90d270
log: remove log "module" system
After comtemplation, the complexity of the logging module system
outweighs its usefulness. This changeset removes the system and restores
lighter weight code paths. As a concession, we can always provide more
context when necessary to log messages to understand them without having
to fork the context for a certain set of calls.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2018-01-18 11:22:13 -08:00
Andrew Pennebaker
1d2a079f08
update to github.com/sirupsen/logrus v1.0.0
Signed-off-by: Andrew Pennebaker <apennebaker@datapipe.com>
2017-07-21 15:39:14 -07:00
Kenfe-Mickael Laventure
c9064df2cf
Discard grpc logs by default
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-06-14 11:58:13 -07:00
Akihiro Suda
727f0a536e vendor: sirupsen/logrus -> Sirupsen/logrus
github.com/docker/docker/pkg/archive requires Sirupsen/logrus.
So let's remove sirupsen/logrus at the moment.

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-01-23 08:50:08 +00:00
Kenfe-Mickael Laventure
aa5ff88bbc Integrate NATS with event subsystem
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-12-12 14:54:47 -08:00
Stephen J Day
aa4a1f851d
log: remove crusty context, replace with shiny
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2016-11-30 17:40:26 -08:00
Stephen J Day
cd4f1f98d8 log: mark grpc messages with module
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2016-11-30 14:07:51 -08:00
Stephen J Day
deb62729ba log: add testing for context logger
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2016-08-02 18:00:48 -07:00
Stephen J Day
5288d8f9fe log: improve module-oriented logging
To improve the output of module logging, we now include a path that
represents the modules that a context has passed through. This makes it
easy to tell if a log line came from a particular module hierarchy.

A helper function, `WithModule`, provides an easy way to mark a context
with a module and inject that module into the logger.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2016-08-02 16:41:49 -07:00
Stephen J Day
41aadb3fb0 log: replace grpc logger with logrus
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2016-05-12 15:53:32 -07:00
Stephen J Day
b8e1fa2e15 log: provide simple context logging
We consolidate simple context logging for use across packages. For now,
one still needs logrus, but we can take this further and avoid the
import at a later time.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2016-03-10 20:00:17 -08:00