betterlog 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +5 -0
- data/Dockerfile +46 -0
- data/Gemfile +5 -1
- data/LICENSE +10 -199
- data/Makefile +78 -0
- data/Rakefile +7 -3
- data/TODO.md +1 -0
- data/VERSION +1 -1
- data/betterlog/healthz.go +71 -0
- data/betterlog.gemspec +20 -10
- data/bin/betterlog +176 -175
- data/bin/betterlog_pusher +34 -0
- data/cmd/betterlog-server/LICENSE +13 -0
- data/cmd/betterlog-server/main.go +165 -0
- data/{log.yml → config/log.yml} +5 -35
- data/lib/betterlog/global_metadata.rb +9 -14
- data/lib/betterlog/log/event.rb +135 -133
- data/lib/betterlog/log/event_formatter.rb +99 -97
- data/lib/betterlog/log/severity.rb +38 -36
- data/lib/betterlog/log.rb +163 -146
- data/lib/betterlog/log_event_formatter.rb +41 -39
- data/lib/betterlog/logger.rb +88 -0
- data/lib/betterlog/notifiers.rb +28 -0
- data/lib/betterlog/railtie.rb +8 -0
- data/lib/betterlog/version.rb +1 -1
- data/lib/betterlog.rb +13 -7
- data/spec/betterlog/global_metadata_spec.rb +38 -0
- data/spec/betterlog/log_spec.rb +221 -0
- data/spec/betterlog/logger_spec.rb +65 -0
- data/spec/spec_helper.rb +13 -0
- metadata +82 -28
- data/betterdocs.gemspec +0 -53
- data/lib/betterdocs/version.rb +0 -8
- data/lib/betterlog/betterlog_railtie.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 811fae89b6d7c4f72b1b6db0a8e8898b19d17902bae49a7eb068471f706fcedd
|
4
|
+
data.tar.gz: a61e8852c1397565ab28904f65c9288bcbbe08b016a21fec087a659e17d78f5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c37b354a7181e6b917158558750d67aed56e9d06da54eb715ae2d930e706c8f24d4cfd8b0a11ae9d5fda5a696896e3c01be6aac8884608bfa1bb479444a22d47
|
7
|
+
data.tar.gz: 8323f0bc5eacacf260423e296b5f318aed09f8235b15611757aad5cb21213cd970ec2a0ccf447bd7456eab6a8ffd7306173f2500a6e6f21f6b0f05f22f409e8e
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Dockerfile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
ARG BASE_IMAGE
|
2
|
+
|
3
|
+
FROM ${BASE_IMAGE} AS builder
|
4
|
+
|
5
|
+
# Update/Upgrade/Add packages for building
|
6
|
+
|
7
|
+
RUN apk add --no-cache bash git go build-base
|
8
|
+
|
9
|
+
# Build happening
|
10
|
+
|
11
|
+
WORKDIR /build/betterlog
|
12
|
+
|
13
|
+
ADD . .
|
14
|
+
|
15
|
+
ENV GOPATH=/build/betterlog/gospace
|
16
|
+
|
17
|
+
RUN make clobber
|
18
|
+
|
19
|
+
RUN go get -u github.com/betterplace/go-init
|
20
|
+
|
21
|
+
RUN make fetch all
|
22
|
+
|
23
|
+
FROM ${BASE_IMAGE} AS runner
|
24
|
+
|
25
|
+
# Update/Upgrade/Add packages
|
26
|
+
|
27
|
+
RUN apk add --no-cache bash ca-certificates
|
28
|
+
|
29
|
+
RUN apk add --no-cache tzdata && \
|
30
|
+
cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime && \
|
31
|
+
echo Europe/Berlin >/etc/timezone && \
|
32
|
+
apk del tzdata
|
33
|
+
|
34
|
+
ARG APP_DIR=/app
|
35
|
+
|
36
|
+
RUN adduser -h ${APP_DIR} -s /bin/bash -D appuser
|
37
|
+
|
38
|
+
RUN mkdir -p /opt/bin
|
39
|
+
|
40
|
+
COPY --from=builder --chown=appuser:appuser /build/betterlog/gospace/bin/go-init /build/betterlog/betterlog-server /opt/bin/
|
41
|
+
|
42
|
+
ENV PATH /opt/bin:${PATH}
|
43
|
+
|
44
|
+
EXPOSE 5514
|
45
|
+
|
46
|
+
CMD [ "/opt/bin/go-init", "-pre", "/bin/sleep 3", "-main", "/opt/bin/betterlog-server" ]
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
@@ -1,202 +1,13 @@
|
|
1
|
-
|
2
|
-
Version 2.0, January 2004
|
3
|
-
http://www.apache.org/licenses/
|
1
|
+
Copyright 2018 Florian Frank
|
4
2
|
|
5
|
-
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
-
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
-
the copyright owner that is granting the License.
|
14
|
-
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
-
other entities that control, are controlled by, or are under common
|
17
|
-
control with that entity. For the purposes of this definition,
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
19
|
-
direction or management of such entity, whether by contract or
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
-
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
-
exercising permissions granted by this License.
|
25
|
-
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
27
|
-
including but not limited to software source code, documentation
|
28
|
-
source, and configuration files.
|
29
|
-
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
31
|
-
transformation or translation of a Source form, including but
|
32
|
-
not limited to compiled object code, generated documentation,
|
33
|
-
and conversions to other media types.
|
34
|
-
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
36
|
-
Object form, made available under the License, as indicated by a
|
37
|
-
copyright notice that is included in or attached to the work
|
38
|
-
(an example is provided in the Appendix below).
|
39
|
-
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
-
the Work and Derivative Works thereof.
|
47
|
-
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
49
|
-
the original version of the Work and any modifications or additions
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
-
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
64
|
-
subsequently incorporated within the Work.
|
65
|
-
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
72
|
-
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
-
where such license applies only to those patent claims licensable
|
79
|
-
by such Contributor that are necessarily infringed by their
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
82
|
-
institute patent litigation against any entity (including a
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
85
|
-
or contributory patent infringement, then any patent licenses
|
86
|
-
granted to You under this License for that Work shall terminate
|
87
|
-
as of the date such litigation is filed.
|
88
|
-
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
91
|
-
modifications, and in Source or Object form, provided that You
|
92
|
-
meet the following conditions:
|
93
|
-
|
94
|
-
(a) You must give any other recipients of the Work or
|
95
|
-
Derivative Works a copy of this License; and
|
96
|
-
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
98
|
-
stating that You changed the files; and
|
99
|
-
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
102
|
-
attribution notices from the Source form of the Work,
|
103
|
-
excluding those notices that do not pertain to any part of
|
104
|
-
the Derivative Works; and
|
105
|
-
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
108
|
-
include a readable copy of the attribution notices contained
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
111
|
-
of the following places: within a NOTICE text file distributed
|
112
|
-
as part of the Derivative Works; within the Source form or
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
114
|
-
within a display generated by the Derivative Works, if and
|
115
|
-
wherever such third-party notices normally appear. The contents
|
116
|
-
of the NOTICE file are for informational purposes only and
|
117
|
-
do not modify the License. You may add Your own attribution
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
120
|
-
that such additional attribution notices cannot be construed
|
121
|
-
as modifying the License.
|
122
|
-
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
124
|
-
may provide additional or different license terms and conditions
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
128
|
-
the conditions stated in this License.
|
129
|
-
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
133
|
-
this License, without any additional terms or conditions.
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
-
the terms of any separate license agreement you may have executed
|
136
|
-
with Licensor regarding such Contributions.
|
137
|
-
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
140
|
-
except as required for reasonable and customary use in describing the
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
-
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
152
|
-
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
158
|
-
incidental, or consequential damages of any character arising as a
|
159
|
-
result of this License or out of the use or inability to use the
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
162
|
-
other commercial damages or losses), even if such Contributor
|
163
|
-
has been advised of the possibility of such damages.
|
164
|
-
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
-
or other liability obligations and/or rights consistent with this
|
169
|
-
License. However, in accepting such obligations, You may act only
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
174
|
-
of your accepting any such warranty or additional liability.
|
175
|
-
|
176
|
-
END OF TERMS AND CONDITIONS
|
177
|
-
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
179
|
-
|
180
|
-
To apply the Apache License to your work, attach the following
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "{}"
|
182
|
-
replaced with your own identifying information. (Don't include
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
184
|
-
comment syntax for the file format. We also recommend that a
|
185
|
-
file or class name and description of purpose be included on the
|
186
|
-
same "printed page" as the copyright notice for easier
|
187
|
-
identification within third-party archives.
|
188
|
-
|
189
|
-
Copyright {yyyy} {name of copyright owner}
|
190
|
-
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
-
you may not use this file except in compliance with the License.
|
193
|
-
You may obtain a copy of the License at
|
194
|
-
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
-
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
-
See the License for the specific language governing permissions and
|
201
|
-
limitations under the License.
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
202
8
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/Makefile
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Pass BASE_IMAGE=alpine:3.10.0
|
2
|
+
DOCKER_IMAGE_LATEST = betterlog
|
3
|
+
DOCKER_IMAGE = $(DOCKER_IMAGE_LATEST):$(REVISION_SHORT)
|
4
|
+
PROJECT_ID = betterplace-183212
|
5
|
+
REMOTE_LATEST_TAG := eu.gcr.io/${PROJECT_ID}/$(DOCKER_IMAGE_LATEST)
|
6
|
+
REMOTE_TAG = eu.gcr.io/$(PROJECT_ID)/$(DOCKER_IMAGE)
|
7
|
+
REVISION := $(shell git rev-parse HEAD)
|
8
|
+
REVISION_SHORT := $(shell echo $(REVISION) | head -c 7)
|
9
|
+
GOPATH := $(shell pwd)/gospace
|
10
|
+
GOBIN = $(GOPATH)/bin
|
11
|
+
|
12
|
+
.EXPORT_ALL_VARIABLES:
|
13
|
+
|
14
|
+
all: betterlog-server
|
15
|
+
|
16
|
+
betterlog-server: cmd/betterlog-server/main.go betterlog/*.go
|
17
|
+
go build -o $@ $<
|
18
|
+
|
19
|
+
local: betterlog-server
|
20
|
+
REDIS_URL=$(REDIS_URL) ./betterlog-server
|
21
|
+
|
22
|
+
fetch: fake-package
|
23
|
+
go get -u github.com/dgrijalva/jwt-go
|
24
|
+
go get -u github.com/labstack/echo
|
25
|
+
go get -u github.com/kelseyhightower/envconfig
|
26
|
+
go get -u github.com/go-redis/redis
|
27
|
+
|
28
|
+
fake-package:
|
29
|
+
rm -rf $(GOPATH)/src/github.com/betterplace/betterlog
|
30
|
+
mkdir -p $(GOPATH)/src/github.com/betterplace
|
31
|
+
ln -s $(shell pwd) $(GOPATH)/src/github.com/betterplace/betterlog
|
32
|
+
|
33
|
+
test:
|
34
|
+
@go test
|
35
|
+
|
36
|
+
coverage:
|
37
|
+
@go test -coverprofile=coverage.out
|
38
|
+
|
39
|
+
coverage-display: coverage
|
40
|
+
@go tool cover -html=coverage.out
|
41
|
+
|
42
|
+
clean:
|
43
|
+
@rm -f betterlog-server coverage.out tags
|
44
|
+
|
45
|
+
clobber: clean
|
46
|
+
@rm -rf $(GOPATH)/*
|
47
|
+
|
48
|
+
tags: clean
|
49
|
+
@gotags -tag-relative=false -silent=true -R=true -f $@ . $(GOPATH)
|
50
|
+
|
51
|
+
build-info:
|
52
|
+
@echo $(DOCKER_IMAGE)
|
53
|
+
|
54
|
+
pull-base:
|
55
|
+
docker pull $(BASE_IMAGE)
|
56
|
+
|
57
|
+
build: pull-base
|
58
|
+
docker build -t $(DOCKER_IMAGE) --build-arg=BASE_IMAGE=$(BASE_IMAGE) .
|
59
|
+
$(MAKE) build-info
|
60
|
+
|
61
|
+
build-force: pull-base
|
62
|
+
docker build -t $(DOCKER_IMAGE) --build-arg=BASE_IMAGE=$(BASE_IMAGE) --no-cache .
|
63
|
+
$(MAKE) build-info
|
64
|
+
|
65
|
+
debug:
|
66
|
+
docker run --rm -it $(DOCKER_IMAGE) bash
|
67
|
+
|
68
|
+
pull:
|
69
|
+
docker pull $(REMOTE_TAG)
|
70
|
+
docker tag $(REMOTE_TAG) $(DOCKER_IMAGE)
|
71
|
+
|
72
|
+
push: build
|
73
|
+
docker tag $(DOCKER_IMAGE) $(REMOTE_TAG)
|
74
|
+
docker push $(REMOTE_TAG)
|
75
|
+
|
76
|
+
push-latest: push
|
77
|
+
docker tag ${DOCKER_IMAGE} ${REMOTE_LATEST_TAG}
|
78
|
+
docker push ${REMOTE_LATEST_TAG}
|
data/Rakefile
CHANGED
@@ -12,19 +12,23 @@ GemHadar do
|
|
12
12
|
test_dir 'spec'
|
13
13
|
ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', 'coverage', '.rvmrc',
|
14
14
|
'.ruby-version', '.AppleDouble', 'tags', '.DS_Store', '.utilsrc',
|
15
|
-
'.bundle', '.byebug_history', 'errors.lst', '.yardoc'
|
15
|
+
'.bundle', '.byebug_history', 'errors.lst', '.yardoc', 'betterlog-server',
|
16
|
+
'gospace'
|
16
17
|
readme 'README.md'
|
17
18
|
title "#{name.camelize}"
|
18
|
-
executables ["betterlog"]
|
19
|
+
executables ["betterlog", "betterlog_pusher"]
|
19
20
|
|
20
21
|
dependency 'tins', '~>1.3', '>=1.3.5'
|
21
|
-
dependency 'rails', '>=3', '<6'
|
22
22
|
dependency 'complex_config'
|
23
23
|
dependency 'file-tail', '~>1.0'
|
24
24
|
dependency 'json', '~>2.0'
|
25
25
|
dependency 'term-ansicolor', '~>1.3'
|
26
|
+
dependency 'redis', '>=2.4'
|
27
|
+
dependency 'excon'
|
26
28
|
|
27
29
|
development_dependency 'rake'
|
30
|
+
development_dependency 'rspec'
|
31
|
+
development_dependency 'simplecov'
|
28
32
|
end
|
29
33
|
|
30
34
|
task :default => :spec
|
data/TODO.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
- `complex_config` config files
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -0,0 +1,71 @@
|
|
1
|
+
package bime
|
2
|
+
|
3
|
+
import (
|
4
|
+
"fmt"
|
5
|
+
"log"
|
6
|
+
"net/http"
|
7
|
+
"os"
|
8
|
+
|
9
|
+
"github.com/labstack/echo"
|
10
|
+
)
|
11
|
+
|
12
|
+
type Health struct {
|
13
|
+
PORT int
|
14
|
+
}
|
15
|
+
|
16
|
+
type Response struct {
|
17
|
+
Hostname string `json:"hostname"`
|
18
|
+
Healthy bool `json:"healthy"`
|
19
|
+
Error string `json:"error,omitempty"`
|
20
|
+
Message string `json:"message,omitempty"`
|
21
|
+
}
|
22
|
+
|
23
|
+
func determineHostname() string {
|
24
|
+
hostname, err := os.Hostname()
|
25
|
+
if err != nil {
|
26
|
+
hostname = "unknown"
|
27
|
+
}
|
28
|
+
return hostname
|
29
|
+
}
|
30
|
+
|
31
|
+
func (health Health) Check() error {
|
32
|
+
return nil
|
33
|
+
}
|
34
|
+
|
35
|
+
func (health Health) ZPage(next echo.HandlerFunc) echo.HandlerFunc {
|
36
|
+
hostname := determineHostname()
|
37
|
+
return func(c echo.Context) error {
|
38
|
+
if c.Path() == "/healthz" {
|
39
|
+
if err := health.Check(); err == nil {
|
40
|
+
return c.JSON(
|
41
|
+
http.StatusOK,
|
42
|
+
Response{
|
43
|
+
Hostname: hostname,
|
44
|
+
Healthy: true,
|
45
|
+
},
|
46
|
+
)
|
47
|
+
} else {
|
48
|
+
log.Printf("error: %v", err)
|
49
|
+
return c.JSON(
|
50
|
+
http.StatusInternalServerError,
|
51
|
+
Response{
|
52
|
+
Hostname: hostname,
|
53
|
+
Healthy: false,
|
54
|
+
Error: err.Error(),
|
55
|
+
Message: "problem detected",
|
56
|
+
},
|
57
|
+
)
|
58
|
+
}
|
59
|
+
} else {
|
60
|
+
return next(c)
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
func StartHealthzEcho(health Health) {
|
66
|
+
e := echo.New()
|
67
|
+
|
68
|
+
e.Use(health.ZPage)
|
69
|
+
log.Printf("Starting :%d/healthz", health.PORT)
|
70
|
+
e.Logger.Fatal(e.Start(fmt.Sprintf(":%d", health.PORT)))
|
71
|
+
}
|
data/betterlog.gemspec
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: betterlog 0.
|
2
|
+
# stub: betterlog 0.2.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "betterlog".freeze
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.2.0"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["betterplace Developers".freeze]
|
11
|
-
s.date = "2019-
|
11
|
+
s.date = "2019-06-27"
|
12
12
|
s.description = "This library provides structure json logging for our rails projects".freeze
|
13
13
|
s.email = "developers@betterplace.org".freeze
|
14
|
-
s.executables = ["betterlog".freeze]
|
15
|
-
s.extra_rdoc_files = ["README.md".freeze, "lib/
|
16
|
-
s.files = [".gitignore".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "
|
14
|
+
s.executables = ["betterlog".freeze, "betterlog_pusher".freeze]
|
15
|
+
s.extra_rdoc_files = ["README.md".freeze, "lib/betterlog.rb".freeze, "lib/betterlog/global_metadata.rb".freeze, "lib/betterlog/log.rb".freeze, "lib/betterlog/log/event.rb".freeze, "lib/betterlog/log/event_formatter.rb".freeze, "lib/betterlog/log/severity.rb".freeze, "lib/betterlog/log_event_formatter.rb".freeze, "lib/betterlog/logger.rb".freeze, "lib/betterlog/notifiers.rb".freeze, "lib/betterlog/railtie.rb".freeze, "lib/betterlog/version.rb".freeze]
|
16
|
+
s.files = [".gitignore".freeze, ".travis.yml".freeze, "Dockerfile".freeze, "Gemfile".freeze, "LICENSE".freeze, "Makefile".freeze, "README.md".freeze, "Rakefile".freeze, "TODO.md".freeze, "VERSION".freeze, "betterlog.gemspec".freeze, "betterlog/healthz.go".freeze, "bin/betterlog".freeze, "bin/betterlog_pusher".freeze, "cmd/betterlog-server/LICENSE".freeze, "cmd/betterlog-server/main.go".freeze, "config/log.yml".freeze, "lib/betterlog.rb".freeze, "lib/betterlog/global_metadata.rb".freeze, "lib/betterlog/log.rb".freeze, "lib/betterlog/log/event.rb".freeze, "lib/betterlog/log/event_formatter.rb".freeze, "lib/betterlog/log/severity.rb".freeze, "lib/betterlog/log_event_formatter.rb".freeze, "lib/betterlog/logger.rb".freeze, "lib/betterlog/notifiers.rb".freeze, "lib/betterlog/railtie.rb".freeze, "lib/betterlog/version.rb".freeze, "spec/betterlog/global_metadata_spec.rb".freeze, "spec/betterlog/log_spec.rb".freeze, "spec/betterlog/logger_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
17
17
|
s.homepage = "http://github.com/betterplace/betterlog".freeze
|
18
18
|
s.rdoc_options = ["--title".freeze, "Betterlog".freeze, "--main".freeze, "README.md".freeze]
|
19
|
-
s.rubygems_version = "3.0.
|
19
|
+
s.rubygems_version = "3.0.3".freeze
|
20
20
|
s.summary = "Structured logging support for bp".freeze
|
21
|
+
s.test_files = ["spec/betterlog/global_metadata_spec.rb".freeze, "spec/betterlog/log_spec.rb".freeze, "spec/betterlog/logger_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
21
22
|
|
22
23
|
if s.respond_to? :specification_version then
|
23
24
|
s.specification_version = 4
|
@@ -25,30 +26,39 @@ Gem::Specification.new do |s|
|
|
25
26
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
27
|
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"])
|
27
28
|
s.add_development_dependency(%q<rake>.freeze, [">= 0"])
|
29
|
+
s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
|
30
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
28
31
|
s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.3", ">= 1.3.5"])
|
29
|
-
s.add_runtime_dependency(%q<rails>.freeze, [">= 3", "< 6"])
|
30
32
|
s.add_runtime_dependency(%q<complex_config>.freeze, [">= 0"])
|
31
33
|
s.add_runtime_dependency(%q<file-tail>.freeze, ["~> 1.0"])
|
32
34
|
s.add_runtime_dependency(%q<json>.freeze, ["~> 2.0"])
|
33
35
|
s.add_runtime_dependency(%q<term-ansicolor>.freeze, ["~> 1.3"])
|
36
|
+
s.add_runtime_dependency(%q<redis>.freeze, [">= 2.4"])
|
37
|
+
s.add_runtime_dependency(%q<excon>.freeze, [">= 0"])
|
34
38
|
else
|
35
39
|
s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"])
|
36
40
|
s.add_dependency(%q<rake>.freeze, [">= 0"])
|
41
|
+
s.add_dependency(%q<rspec>.freeze, [">= 0"])
|
42
|
+
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
37
43
|
s.add_dependency(%q<tins>.freeze, ["~> 1.3", ">= 1.3.5"])
|
38
|
-
s.add_dependency(%q<rails>.freeze, [">= 3", "< 6"])
|
39
44
|
s.add_dependency(%q<complex_config>.freeze, [">= 0"])
|
40
45
|
s.add_dependency(%q<file-tail>.freeze, ["~> 1.0"])
|
41
46
|
s.add_dependency(%q<json>.freeze, ["~> 2.0"])
|
42
47
|
s.add_dependency(%q<term-ansicolor>.freeze, ["~> 1.3"])
|
48
|
+
s.add_dependency(%q<redis>.freeze, [">= 2.4"])
|
49
|
+
s.add_dependency(%q<excon>.freeze, [">= 0"])
|
43
50
|
end
|
44
51
|
else
|
45
52
|
s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"])
|
46
53
|
s.add_dependency(%q<rake>.freeze, [">= 0"])
|
54
|
+
s.add_dependency(%q<rspec>.freeze, [">= 0"])
|
55
|
+
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
47
56
|
s.add_dependency(%q<tins>.freeze, ["~> 1.3", ">= 1.3.5"])
|
48
|
-
s.add_dependency(%q<rails>.freeze, [">= 3", "< 6"])
|
49
57
|
s.add_dependency(%q<complex_config>.freeze, [">= 0"])
|
50
58
|
s.add_dependency(%q<file-tail>.freeze, ["~> 1.0"])
|
51
59
|
s.add_dependency(%q<json>.freeze, ["~> 2.0"])
|
52
60
|
s.add_dependency(%q<term-ansicolor>.freeze, ["~> 1.3"])
|
61
|
+
s.add_dependency(%q<redis>.freeze, [">= 2.4"])
|
62
|
+
s.add_dependency(%q<excon>.freeze, [">= 0"])
|
53
63
|
end
|
54
64
|
end
|