Commit Graph

34 Commits

Author SHA1 Message Date
23023fa5ed Ensure reader position is at the end after tailing
After tailing a file, if the number of lines requested is > the number
of lines in the file, this would cause a json unmarshalling error to
occur when we later try to go follow the file.
So brute force set it to the end if any tailing occurred.

There is potential that there could be some missing log messages if logs
are being written very quickly, however I was not able to make this
happen even with `while true; do echo hello; done`, so this is probably
acceptable.

While testing this I also found a panic in LogWatcher.Close can be
called twice due to a race. Fix channel close to only close when there
has been no signal to the channel.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: c57faa91e2dab72a0a0905dc10e5cbdf55b545f5
Component: engine
2015-08-01 08:00:28 -04:00
90287c6171 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>
Upstream-commit: ccbe539e86dfbb8749c09763ddfd73bf10ac57cc
Component: engine
2015-07-29 13:09:39 -07:00
9da89dbbd1 Doc fixes in logger, update NewCopier method
Signed-off-by: Ankush Agarwal <ankushagarwal11@gmail.com>
Upstream-commit: 41d85c014defd96cda06abac73554d9f9d1de0d8
Component: engine
2015-07-29 10:05:46 -07:00
905c09e034 Use math.MaxInt32 instead of math.MaxUint32
I think it was original intention, because even half of a comment was about
MaxInt32.

Fix #15038

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: eb45602d2fa0fac8a694d2afb1c59ef60b0e1f77
Component: engine
2015-07-27 13:11:16 -07:00
ffc7323b60 Fix option validation for log-drivers without it
There is no option validation for "journald" log-driver, so it makes no
sense to fail in that case.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: d68c55bc72625bce226971ef6e760530e9a15ce3
Component: engine
2015-07-24 09:00:53 -07:00
5104b34c44 Split reader interface from logger interface
Implement new reader interface on jsonfile.
Moves jsonlog decoding from daemon to jsonfile logger.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: c0391bf5545afef5e675138556c39e4c0e9bf91b
Component: engine
2015-07-21 20:47:31 -04:00
fb988a52e9 add support for maximum log size, and max number of log files
Signed-off-by: wlan0 <sidharthamn@gmail.com>
Upstream-commit: 9b782d3af322bd8d9cf857d63eb7f2e0fe484c90
Component: engine
2015-07-02 06:26:06 -07:00
22652d4dad Add new logging driver: fluentd
Signed-off-by: TAGOMORI Satoshi <tagomoris@gmail.com>
Upstream-commit: 361a582ba0bccea04a8ea1799e68779fa66abb9f
Component: engine
2015-06-26 11:03:11 +09:00
f157b240b8 Add --log-opt to specify facility for syslog driver
Signed-off-by: Dennis Docter <dennis@d23.nl>
Upstream-commit: 609e7b0a55d4082fce40eabae3a06ca57c188ba5
Component: engine
2015-06-23 14:04:25 +02:00
0c0594818f add UDP GELF logging-driver
allows to send container logs to Graylog or Logstash.

Signed-off-by: Marius Sturm <marius@graylog.com>
Upstream-commit: 96d06e106fb9e35e5a526054d3aa0152152a9cc4
Component: engine
2015-06-10 20:21:50 +02:00
f8248bbabf Add syslog-tag option for syslog log-driver
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: a81af2e26a19cca0ffb8cbfa619169d55d604789
Component: engine
2015-06-02 12:43:00 -07:00
24139366a7 Merge pull request #13564 from burke/fix-memory-leak
Use bufio.Reader instead of bufio.Scanner for logger.Copier
Upstream-commit: c42810fe9981c07e7de55aa65af44d618dd4e6ce
Component: engine
2015-05-29 13:37:15 -07:00
c9400d42cc Use bufio.Reader instead of bufio.Scanner for logger.Copier
When using a scanner, log lines over 64K will crash the Copier with
bufio.ErrTooLong. Subsequently, the ioutils.bufReader will grow without
bound as the logs are no longer being flushed to disk.

Signed-off-by: Burke Libbey <burke.libbey@shopify.com>
Upstream-commit: f779cfc5d8b8f0686c3849a3bd4ab0480675180d
Component: engine
2015-05-29 12:29:42 -04:00
8d306cf8a5 Add syslog-address log-opt
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
Upstream-commit: e8c88d253337776a6075c9db69140ce2c5014622
Component: engine
2015-05-29 00:42:11 +02:00
bcf5956dfc Pass -log-opts map to logdrivers
Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
Upstream-commit: 8b11592d699df669b529e34658ef2d870c8a75f8
Component: engine
2015-05-18 16:50:14 +00:00
38fd09288b Windows: Factor out syslog and journald
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 655a58e27bfcfd2494bb5d46f95cb49d655ad17a
Component: engine
2015-05-14 10:34:09 -07:00
b1b57c9cd4 daemon: Logging drivers refactoring
- noplog driver pkg for '--log-driver=none' (null object pattern)
- centralized factory for log drivers (instead of case/switch)
- logging drivers registers themselves to factory upon import
  (easy plug/unplug of drivers in daemon/logdrivers.go)
- daemon now doesn't start with an invalid log driver
- Name() method of loggers is actually now their cli names (made it useful)
- generalized Read() logic, made it unsupported except json-file (preserves
  existing behavior)

Spotted some duplication code around processing of legacy json-file
format, didn't touch that and refactored in both places.

Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
Upstream-commit: 3a8728b431df07249ad913ea9a12e27dc39b8956
Component: engine
2015-05-12 19:11:52 +00:00
72fc3b7751 journald log driver: use CONTAINER_ID field for container id
This patch modifies the journald log driver to store the container ID in
a field named CONTAINER_ID, rather than (ab)using the MESSAGE_ID field.
Additionally, this adds the CONTAINER_ID_FULL field containing the
complete container ID and CONTAINER_NAME, containing the container name.

When using the journald log driver, this permits you to see log messages
from a particular container like this:

    # journalctl CONTAINER_ID=a9238443e193

Example output from "journalctl -o verbose" includes the following:

    CONTAINER_ID=27aae7361e67
    CONTAINER_ID_FULL=27aae7361e67e2b4d3864280acd2b80e78daf8ec73786d8b68f3afeeaabbd4c4
    CONTAINER_NAME=web

Closes: #12864
Signed-off-by: Lars Kellogg-Stedman <lars@redhat.com>
Upstream-commit: 869ecba652294e069874c83591d6f1b469d7cc32
Component: engine
2015-04-30 10:42:27 -04:00
b04ccc089c Add journald as a supported logger for containers
Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Upstream-commit: 364287b74118de4f04d049426ef37fa9936d2065
Component: engine
2015-04-21 12:57:54 -04:00
78dcc43512 Change syslog format and facility
This patch changes two things

1. Set facility to LOG_DAEMON
2. Remove ": " from tag so that the tag + pid become a single column in
   the log

Signed-off-by: Darren Shepherd <darren@rancher.com>
Upstream-commit: 05641ccffc5088a382fa3bfb21f1276ccb6c1fc0
Component: engine
2015-04-15 12:46:43 -07:00
73f3660a47 move syslog-tag to syslog.New function
Signed-off-by: Deng Guangxing <dengguangxing@huawei.com>
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Upstream-commit: 4f91a333d5c9d66ce109c36e7261dbfd3382ebbf
Component: engine
2015-04-13 11:24:18 -07:00
2ebb5f4928 daemon/logger/jsonfilelog: avoid some allocations
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
Upstream-commit: 132da3f036287896cb3ba9f9f2573ad36bbb69cc
Component: engine
2015-04-02 18:33:23 +03:00
68100310d8 Removed unused "mutex" field
fixes #11659

Signed-off-by: Alena Prokharchyk <alena@rancher.com>
Upstream-commit: dabd8a02aeff8b2122efa0b55de4ba52c429f936
Component: engine
2015-03-23 19:05:21 -07:00
59aa846db8 Syslog.Log - Remove redundant cast of msg.Line []byte to string as
it's a fmt.Sprintf responsibility.

Signed-off-by: Anton Tiurin <noxiouz@yandex.ru>
Upstream-commit: f2c7b4d7437443d469b2247362835af02ccef385
Component: engine
2015-03-24 01:35:54 +03:00
974bfa30e6 Merge pull request #11654 from runcom/11650-syslog-close-redunant-nil-check
syslog Close() - Remove redunant nil check, s.writer cannot be nil
Upstream-commit: 2717302cc69c865cfec02fb48b3cb173d6980364
Component: engine
2015-03-23 12:32:26 -07:00
84d2a9e3ec Remove redunant nil check, s.writer cannot be nil
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
Upstream-commit: e600df2d9732b8c40d056563e361ded6cd5ce773
Component: engine
2015-03-23 20:03:24 +01:00
1ef60888a8 Refactor syslog Log else clause
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
Upstream-commit: 8f025aae36fd040d8d2617890b258b5460ae44db
Component: engine
2015-03-23 20:01:01 +01:00
dad3640059 Merge pull request #11458 from ibuildthecloud/syslog
Add syslog logging driver
Upstream-commit: 65e21f570358f46f6ad0f8fa2cd3394706ba169d
Component: engine
2015-03-23 11:34:33 -07:00
a7d21898b0 add syslog driver
Signed-off-by: wlan0 <sid@rancher.com>
Upstream-commit: eaecd8b1b5871a4d17be27e3615106587eec1d3a
Component: engine
2015-03-21 18:01:18 -07:00
7ce99f1b4f Merge pull request #11471 from LK4D4/wait_for_copier
Wait for copier finishing it's work before closing logger
Upstream-commit: 474f58e2e73de477e6b9a827e100f3f22f52048a
Component: engine
2015-03-18 15:41:12 -07:00
783795eacd Wait for copier finishing it's work before closing logger
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: b6a42673abb8c2df5920343b9144a4ce422b2d50
Component: engine
2015-03-18 13:48:01 -07:00
4af8cc6694 Protect jsonfilelog writes with mutex
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: bd8661e8fafd5f80ce12fa966b9f8e990b7d7714
Component: engine
2015-03-18 13:00:53 -07:00
0f5871ff56 Default 'json-file' logging driver and none logging driver
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: 47a6afb93f7f71c7ef7dc692c0f50ac81b5a8c98
Component: engine
2015-03-13 12:13:21 -07:00
16d307ce0f Interface Logger for logging drivers
Also there is aux datastructure Copier which can copy lines from streams
to Loggers

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: 14887e2e1f8d11f30ab8c25beed0ff9e70354005
Component: engine
2015-03-13 11:46:59 -07:00