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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57cf408499489e3a2a0f7bf2fc51667688ee816e7797984fe4c27ab3393d486a
4
- data.tar.gz: a330c835cf6452a13e3b36727f5d296480a22c8b22e12e887df542ff594db450
3
+ metadata.gz: 975990d950f8eb2ee21cfbbf52fa8472f8a706a02a01728e76e40005ca5807d3
4
+ data.tar.gz: 74ec7d2ce187050e66d4ff5c424daffb99a18759e987a66a7340ec5edcdf16c1
5
5
  SHA512:
6
- metadata.gz: eb3d0ce4c94f68b40c704dbe9cb6de03d25cd422b358039536197ebbc0d5f34b53c6c6f39679fae71a3390d5b619acbe2348d826fdf9534407809c5818db09bf
7
- data.tar.gz: 0236ab4073d2293e01f1cdc6dbf0157c5d0cb481c2ba1db5069000592ea7d21cdca58f998b04dd505d34ad5718dbbb1020a56b9a77eaceac6ebfdc0a9ecd9fe2
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 ["betterlog", "betterlog_pusher"]
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.2.2
1
+ 0.3.0
@@ -1,19 +1,19 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: betterlog 0.2.2 ruby lib
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.2.2"
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-04"
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
@@ -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
@@ -1,6 +1,6 @@
1
1
  module Betterlog
2
2
  # Betterlog version
3
- VERSION = '0.2.2'
3
+ VERSION = '0.3.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
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.2.2
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-04 00:00:00.000000000 Z
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