betterlog 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/betterlog.gemspec +5 -5
- data/bin/betterlog_sink +47 -0
- data/lib/betterlog/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 975990d950f8eb2ee21cfbbf52fa8472f8a706a02a01728e76e40005ca5807d3
|
4
|
+
data.tar.gz: 74ec7d2ce187050e66d4ff5c424daffb99a18759e987a66a7340ec5edcdf16c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f38d883bf8935c90af49649ed0627b2dc600cb992d03d746be12586cca817efb04820b55455b4f209f405edf1dee8400a950f7a283fa1019719d71d629f48f9c
|
7
|
+
data.tar.gz: 1ac776bcbed6cafb804e25a6a1e4d41836bb232ef9b70b04d09fc6c6a80010c2bd187a88f3167495f2bff4fcd6fad34f55bada5e4e13801ed8dd5c3e2d1c505f
|
data/README.md
CHANGED
@@ -1,3 +1,34 @@
|
|
1
1
|
# betterlog
|
2
2
|
|
3
|
+
## Description
|
4
|
+
|
3
5
|
Logging tools for betterplace structured logging
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
### `betterlog`
|
10
|
+
|
11
|
+
TODO
|
12
|
+
|
13
|
+
### `betterlog_pusher`
|
14
|
+
|
15
|
+
TODO
|
16
|
+
|
17
|
+
### `betterlog_sink`
|
18
|
+
|
19
|
+
This is a small wrapper around the `kubectl logs…` command,
|
20
|
+
see `kubectl help logs` for the options.
|
21
|
+
|
22
|
+
To tail a log and prettify the output just call and pipe to the `betterlog`
|
23
|
+
executable:
|
24
|
+
|
25
|
+
```
|
26
|
+
$ betterlog_sink --since=1m -f | betterlog
|
27
|
+
```
|
28
|
+
|
29
|
+
The sink always defaults to the production logfile, to switch the context to
|
30
|
+
staging, prepend the command with the `LOG_ENV` env variable like so:
|
31
|
+
|
32
|
+
```
|
33
|
+
$ LOG_ENV=staging betterlog_sink -f | betterlog
|
34
|
+
```
|
data/Rakefile
CHANGED
@@ -16,7 +16,7 @@ GemHadar do
|
|
16
16
|
'gospace'
|
17
17
|
readme 'README.md'
|
18
18
|
title "#{name.camelize}"
|
19
|
-
executables [
|
19
|
+
executables %w[ betterlog betterlog_pusher betterlog_sink ]
|
20
20
|
|
21
21
|
dependency 'tins', '~>1.3', '>=1.3.5'
|
22
22
|
dependency 'complex_config'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/betterlog.gemspec
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: betterlog 0.
|
2
|
+
# stub: betterlog 0.3.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.3.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-07-
|
11
|
+
s.date = "2019-07-15"
|
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, "betterlog_pusher".freeze]
|
14
|
+
s.executables = ["betterlog".freeze, "betterlog_pusher".freeze, "betterlog_sink".freeze]
|
15
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/config.go".freeze, "betterlog/healthz.go".freeze, "betterlog/redis_cert_cache.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]
|
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/config.go".freeze, "betterlog/healthz.go".freeze, "betterlog/redis_cert_cache.go".freeze, "bin/betterlog".freeze, "bin/betterlog_pusher".freeze, "bin/betterlog_sink".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
19
|
s.rubygems_version = "3.0.3".freeze
|
data/bin/betterlog_sink
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# vim: set ft=ruby et sw=2 ts=2:
|
3
|
+
|
4
|
+
require 'betterlog'
|
5
|
+
require 'complex_config/rude'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
LOG_ENV = ENV.fetch('LOG_ENV', 'production')
|
9
|
+
|
10
|
+
ENV['KUBECONFIG'] = File.join(
|
11
|
+
ENV.fetch('HOME'),
|
12
|
+
'.kube',
|
13
|
+
"betterlog-#{LOG_ENV}"
|
14
|
+
)
|
15
|
+
|
16
|
+
@config = complex_config.log(LOG_ENV).sink
|
17
|
+
|
18
|
+
def authenticate
|
19
|
+
return if File.exist?(ENV['KUBECONFIG'])
|
20
|
+
context = [
|
21
|
+
'gke',
|
22
|
+
@config.cluster.project,
|
23
|
+
@config.cluster.zone,
|
24
|
+
@config.cluster.name,
|
25
|
+
] * ?_
|
26
|
+
system(%{
|
27
|
+
gcloud --no-user-output-enabled container clusters get-credentials \
|
28
|
+
#{@config.cluster.name.inspect} \
|
29
|
+
--zone #{@config.cluster.zone.inspect} \
|
30
|
+
--project #{@config.cluster.project.inspect}
|
31
|
+
}) or fail "failed to authenticate for context #{context.inspect}"
|
32
|
+
end
|
33
|
+
|
34
|
+
authenticate
|
35
|
+
|
36
|
+
pods = JSON(
|
37
|
+
%x{ kubectl -n #{@config.namespace} -ojson get pods },
|
38
|
+
object_class: JSON::GenericObject
|
39
|
+
)
|
40
|
+
|
41
|
+
if pod = pods.items.find { |i| i.metadata.labels.app == @config.source }
|
42
|
+
system %{
|
43
|
+
kubectl logs -n #{@config.namespace} #{ARGV.join(' ')} #{pod.metadata.name}
|
44
|
+
}
|
45
|
+
else
|
46
|
+
exit 1
|
47
|
+
end
|
data/lib/betterlog/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: betterlog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- betterplace Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|
@@ -175,6 +175,7 @@ email: developers@betterplace.org
|
|
175
175
|
executables:
|
176
176
|
- betterlog
|
177
177
|
- betterlog_pusher
|
178
|
+
- betterlog_sink
|
178
179
|
extensions: []
|
179
180
|
extra_rdoc_files:
|
180
181
|
- README.md
|
@@ -206,6 +207,7 @@ files:
|
|
206
207
|
- betterlog/redis_cert_cache.go
|
207
208
|
- bin/betterlog
|
208
209
|
- bin/betterlog_pusher
|
210
|
+
- bin/betterlog_sink
|
209
211
|
- cmd/betterlog-server/LICENSE
|
210
212
|
- cmd/betterlog-server/main.go
|
211
213
|
- config/log.yml
|