Skip to content

Commit 1a496bb

Browse files
authored
Merge pull request #86 from rchicoli/organize-code
Organize code
2 parents 3577c2b + 0644391 commit 1a496bb

File tree

5 files changed

+207
-127
lines changed

5 files changed

+207
-127
lines changed

Gopkg.lock

Lines changed: 33 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ $ docker run --rm -ti \
183183
--log-opt elasticsearch-username=elastic \
184184
--log-opt elasticsearch-password=changeme \
185185
--log-opt elasticsearch-sniff=false \
186-
--log-opt elasticsearch-index=docker \
186+
--log-opt elasticsearch-index=docker-%F \
187187
--log-opt elasticsearch-type=log \
188188
--log-opt elasticsearch-timeout=10 \
189189
--log-opt elasticsearch-version=5 \
@@ -193,7 +193,7 @@ $ docker run --rm -ti \
193193
--log-opt elasticsearch-bulk-size=1024 \
194194
--log-opt elasticsearch-bulk-flush-interval=1s \
195195
--log-opt elasticsearch-bulk-stats=false \
196-
alpine echo this is a test logging message
196+
alpine echo -n "this is a test logging message"
197197
```
198198

199199
Search in Elasticsearch for the log message:
@@ -202,7 +202,7 @@ Search in Elasticsearch for the log message:
202202
$ curl 127.0.0.1:9200/docker/log/_search\?pretty=true
203203

204204
{
205-
"_index" : "docker",
205+
"_index" : "docker-2006.01.02",
206206
"_type" : "log",
207207
"_id" : "AWCywmj6Dipxk6-_e8T5",
208208
"_score" : 1.0,
@@ -215,7 +215,7 @@ $ curl 127.0.0.1:9200/docker/log/_search\?pretty=true
215215
"source" : "stdout",
216216
"timestamp" : "2018-01-18T21:45:30.294363869Z",
217217
"partial" : false,
218-
"message" : "this is a test message\r"
218+
"message" : "this is a test message"
219219
}
220220
}
221221
```

ROADMAP.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Goals:
1010
- [ ] Create an API for dumping or changing config on the fly
1111
- [ ] Parse partial log messages and merge them, if wished
1212
- [ ] Add performance tests
13+
- [ ] Implement Readlog capability
1314
- [ ] Add metrics
1415

1516
## Docker Log Elasticsearch 1.0.0
@@ -18,7 +19,7 @@ Goals:
1819

1920
- [ ] Write unit tests
2021
- [X] Create a Continuous Integration of this project in order to avoid lots of manual interventions.
21-
- [ ] Captch labels and environments
22+
- [X] Captch labels and environments
2223
- [X] Add an extra user option, e.g. `--log-opt elasticsearch-fields=containerName,containerID,containerLogLine` so for a free pick of docker info log
2324
- [ ] Add the capability of multilines for Java Exceptions
2425
- [X] Add HTTPS Support and Skip Certificate Verify
@@ -28,6 +29,5 @@ Goals:
2829
- [X] Implement bulk inserts
2930
- [X] Implement queue size and batch size
3031
- [X] if number of requests or batch size have been reached, send messages to elasticsearch
31-
- [ ] Implement Readlog capability
3232
- [X] Implement grok for parsing docker logs
3333
- [ ] Add CONTRIBUTING file

main.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/Sirupsen/logrus"
7+
log "github.com/Sirupsen/logrus"
88
"github.com/docker/go-plugins-helpers/sdk"
99

1010
"github.com/rchicoli/docker-log-elasticsearch/pkg/docker"
1111
)
1212

13-
var logLevels = map[string]logrus.Level{
14-
"debug": logrus.DebugLevel,
15-
"info": logrus.InfoLevel,
16-
"warn": logrus.WarnLevel,
17-
"error": logrus.ErrorLevel,
13+
var logLevels = map[string]log.Level{
14+
"debug": log.DebugLevel,
15+
"info": log.InfoLevel,
16+
"warn": log.WarnLevel,
17+
"error": log.ErrorLevel,
1818
}
1919

2020
func main() {
@@ -24,8 +24,8 @@ func main() {
2424
levelVal = "info"
2525
}
2626
if level, exists := logLevels[levelVal]; exists {
27-
logrus.SetLevel(level)
28-
logrus.SetFormatter(&logrus.TextFormatter{
27+
log.SetLevel(level)
28+
log.SetFormatter(&log.TextFormatter{
2929
DisableTimestamp: true,
3030
})
3131
} else {

0 commit comments

Comments
 (0)