insights-loggers-ruby 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/insights/loggers/cloud_watch.rb +33 -0
- data/lib/insights/loggers/container.rb +18 -0
- data/lib/insights/loggers/factory.rb +10 -0
- data/lib/insights/loggers/std_error_logger.rb +2 -1
- data/lib/insights/loggers/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: b3c5b0ec28bca5abab1df123d3c7156f2d6121ed47cb2cfc85aaff4e46913704
|
4
|
+
data.tar.gz: 407cab2b0891fdbba9427961efd53fd9e32e64de0547cd7ab90696fa386ed8d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe581909260b999d40c69934063acaa2939ce3a19b4c07b35a9a60613343d294946d00ae67b6b49e66ddb14147d740933b40fba2485a41c0fbdb16e69c139c5a
|
7
|
+
data.tar.gz: 45451921677cdc7963e216e38508a524d8cc8f06e869f257f54acb74b85556df480cac1559c50fcfdeb62c9502ca57f9aa902192c44cd0a34664b75d22e36a68
|
data/README.md
CHANGED
@@ -45,6 +45,7 @@ ManageIQ::Loggers::Base
|
|
45
45
|
ManageIQ::Loggers::Container
|
46
46
|
ManageIQ::Loggers::CloudWatch
|
47
47
|
ManageIQ::Loggers::Journald
|
48
|
+
Insights::Loggers::Container
|
48
49
|
Insights::Loggers::StdErrorLogger
|
49
50
|
TopologicalInventory::Providers::Common::Logger
|
50
51
|
```
|
@@ -80,7 +81,7 @@ Standard error logger produces formatted output:
|
|
80
81
|
"pid":11561, # process id
|
81
82
|
"tid":"3fd1d4c2ffd4", # thread id
|
82
83
|
"service": "progname",
|
83
|
-
"level":"warning", #info, warning, error, debug
|
84
|
+
"level":"warning", # info(default), warning, error, debug
|
84
85
|
"message":"test",
|
85
86
|
"request_id": "REQ_ID", # Thread.current[:request_id]
|
86
87
|
"tags":["MyApp"],
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# inspired by https://github.com/ManageIQ/manageiq-loggers/blob/master/lib/manageiq/loggers/cloud_watch.rb
|
2
|
+
require 'active_support/core_ext/string'
|
3
|
+
require 'active_support/logger'
|
4
|
+
|
5
|
+
module Insights
|
6
|
+
module Loggers
|
7
|
+
class CloudWatch < ManageIQ::Loggers::Base
|
8
|
+
NAMESPACE_FILE = "/var/run/secrets/kubernetes.io/serviceaccount/namespace".freeze
|
9
|
+
|
10
|
+
def self.new(*args)
|
11
|
+
access_key_id = ENV["CW_AWS_ACCESS_KEY_ID"].presence
|
12
|
+
secret_access_key = ENV["CW_AWS_SECRET_ACCESS_KEY"].presence
|
13
|
+
log_group_name = ENV["CLOUD_WATCH_LOG_GROUP"].presence
|
14
|
+
log_stream_name = ENV["HOSTNAME"].presence
|
15
|
+
container_logger = Insights::Loggers::Container.new
|
16
|
+
|
17
|
+
return container_logger unless access_key_id && secret_access_key && log_group_name && log_stream_name
|
18
|
+
|
19
|
+
require 'cloudwatchlogger'
|
20
|
+
|
21
|
+
creds = {:access_key_id => access_key_id, :secret_access_key => secret_access_key}
|
22
|
+
cloud_watch_logdev = CloudWatchLogger::Client.new(creds, log_group_name, log_stream_name)
|
23
|
+
super(cloud_watch_logdev).tap { |logger| logger.extend(ActiveSupport::Logger.broadcast(container_logger)) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(logdev, *args)
|
27
|
+
super
|
28
|
+
self.formatter = ManageIQ::Loggers::Container::Formatter.new
|
29
|
+
self.level = ENV['LOG_LEVEL'] if ENV['LOG_LEVEL']
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'active_support/core_ext/string'
|
2
|
+
require 'active_support/logger'
|
3
|
+
|
4
|
+
module Insights
|
5
|
+
module Loggers
|
6
|
+
class Container < ManageIQ::Loggers::Container
|
7
|
+
def initialize(logdev = STDOUT, *args)
|
8
|
+
super
|
9
|
+
self.level = ENV['CONTAINER_LOG_LEVEL'] || ENV['LOG_LEVEL'] || DEBUG
|
10
|
+
end
|
11
|
+
|
12
|
+
def level=(new_level)
|
13
|
+
# overwrite method ManageIQ::Loggers::Container#level=
|
14
|
+
method(__method__).super_method.super_method.call(new_level)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -55,6 +55,7 @@ module Insights
|
|
55
55
|
when "Insights::Loggers::StdErrorLogger"
|
56
56
|
require "manageiq/loggers/base"
|
57
57
|
require "manageiq/loggers/container"
|
58
|
+
require "insights/loggers/container"
|
58
59
|
require "insights/loggers/std_error_logger"
|
59
60
|
if args && args[:extend_module]
|
60
61
|
library_path = EXTENDED_LIBRARY_FROM_MODULE[args[:extend_module]]
|
@@ -62,8 +63,17 @@ module Insights
|
|
62
63
|
|
63
64
|
require EXTENDED_LIBRARY_FROM_MODULE[args[:extend_module]]
|
64
65
|
end
|
66
|
+
when "Insights::Loggers::CloudWatch"
|
67
|
+
require "manageiq/loggers/base"
|
68
|
+
require "manageiq/loggers/container"
|
69
|
+
require "insights/loggers/container"
|
70
|
+
require "insights/loggers/cloud_watch"
|
65
71
|
when "TopologicalInventory::Providers::Common::Logger"
|
66
72
|
require "topological_inventory/providers/common/logging"
|
73
|
+
when "Insights::Loggers::Container"
|
74
|
+
require "manageiq/loggers/base"
|
75
|
+
require "manageiq/loggers/container"
|
76
|
+
require "insights/loggers/container"
|
67
77
|
else
|
68
78
|
raise ArgumentError, "Can't load libraries for #{logger_class}."
|
69
79
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module Insights
|
2
2
|
module Loggers
|
3
|
-
class StdErrorLogger <
|
3
|
+
class StdErrorLogger < Container
|
4
4
|
def initialize(*args)
|
5
5
|
super
|
6
6
|
self.reopen(STDERR)
|
7
7
|
self.formatter = Formatter.new
|
8
|
+
self.level = INFO
|
8
9
|
end
|
9
10
|
|
10
11
|
def app_name_for_formatter(app_name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: insights-loggers-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Insights Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -178,6 +178,8 @@ files:
|
|
178
178
|
- insights-loggers-ruby.gemspec
|
179
179
|
- lib/insights-loggers.rb
|
180
180
|
- lib/insights/loggers.rb
|
181
|
+
- lib/insights/loggers/cloud_watch.rb
|
182
|
+
- lib/insights/loggers/container.rb
|
181
183
|
- lib/insights/loggers/factory.rb
|
182
184
|
- lib/insights/loggers/std_error_logger.rb
|
183
185
|
- lib/insights/loggers/version.rb
|