manageiq-loggers 0.2.0 → 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/CHANGELOG.md +6 -0
- data/README.md +8 -0
- data/lib/manageiq/loggers.rb +1 -0
- data/lib/manageiq/loggers/cloud_watch.rb +31 -0
- data/lib/manageiq/loggers/journald.rb +56 -0
- data/lib/manageiq/loggers/version.rb +1 -1
- data/manageiq-loggers.gemspec +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57e42ce8c9d94d968cd0f341fe4809ed825d7686
|
4
|
+
data.tar.gz: accdb3174fb08b2c7f8c1f544a29df6af779901f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ce90c2eafe1bd650f5c987256614e3aafda8eb87e826b58fd1b1c1481168cb8f213699747f9742e3d161d2d7de3873670fe49a6ffe84f63c6a08fcabd237b2e
|
7
|
+
data.tar.gz: 292d0d0cb8e632f2e833bd7809fdc158af53aa6f91e4cd6e48f45e8d72ce7421f9dfcdc154dab48d8188e5a5d23e90b075bd12dd3960f266dc2134d5df07b47b
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,12 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
5
5
|
|
6
|
+
## [0.3.0] - 2019-05-30
|
7
|
+
|
8
|
+
## Added
|
9
|
+
- Add a Journald Logger [(#5)](https://github.com/ManageIQ/manageiq-loggers/pull/5)
|
10
|
+
- Add a cloud watch logger [(#9)](https://github.com/ManageIQ/manageiq-loggers/pull/9)
|
11
|
+
|
6
12
|
## [0.2.0] - 2019-05-03
|
7
13
|
|
8
14
|
## Added
|
data/README.md
CHANGED
@@ -23,6 +23,14 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
$ gem install manageiq-loggers
|
25
25
|
|
26
|
+
## Dependencies
|
27
|
+
|
28
|
+
Some loggers require additional gems to function correctly. These gems are not specified as dependencies of this gem directly because they may not be needed for all users of manageiq-loggers
|
29
|
+
|
30
|
+
To use the `Journald` logger, users must specify the `systemd-journal` gem as a dependency
|
31
|
+
|
32
|
+
To use the `CloudWatch` logger, users must specify the `cloudwatchlogger` gem as a dependency
|
33
|
+
|
26
34
|
## Development
|
27
35
|
|
28
36
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/manageiq/loggers.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'active_support/core_ext/string'
|
2
|
+
|
3
|
+
module ManageIQ
|
4
|
+
module Loggers
|
5
|
+
class CloudWatch < Base
|
6
|
+
NAMESPACE_FILE = "/var/run/secrets/kubernetes.io/serviceaccount/namespace".freeze
|
7
|
+
|
8
|
+
def self.new(*args)
|
9
|
+
access_key_id = ENV["CW_AWS_ACCESS_KEY_ID"].presence
|
10
|
+
secret_access_key = ENV["CW_AWS_SECRET_ACCESS_KEY"].presence
|
11
|
+
log_group_name = ENV["CLOUD_WATCH_LOG_GROUP"].presence
|
12
|
+
log_stream_name = File.exist?(NAMESPACE_FILE) ? File.read(NAMESPACE_FILE) : nil
|
13
|
+
|
14
|
+
unless access_key_id && secret_access_key && log_group_name && log_stream_name
|
15
|
+
return ManageIQ::Loggers::Container.new
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'cloudwatchlogger'
|
19
|
+
|
20
|
+
creds = {:access_key_id => access_key_id, :secret_access_key => secret_access_key}
|
21
|
+
cloud_watch_logdev = CloudWatchLogger::Client.new(creds, log_group_name, log_stream_name)
|
22
|
+
super(cloud_watch_logdev)
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(logdev, *args)
|
26
|
+
super
|
27
|
+
self.formatter = ManageIQ::Loggers::Container::Formatter.new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module ManageIQ
|
2
|
+
module Loggers
|
3
|
+
class Journald < Base
|
4
|
+
def initialize(logdev = nil, *args)
|
5
|
+
require "systemd-journal"
|
6
|
+
|
7
|
+
super(logdev, *args)
|
8
|
+
self.formatter = Formatter.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def filename
|
12
|
+
"journald"
|
13
|
+
end
|
14
|
+
|
15
|
+
def add(severity, message = nil, progname = nil)
|
16
|
+
severity ||= Logger::UNKNOWN
|
17
|
+
return true if severity < @level
|
18
|
+
|
19
|
+
progname ||= @progname
|
20
|
+
|
21
|
+
if message.nil?
|
22
|
+
if block_given?
|
23
|
+
message = yield
|
24
|
+
else
|
25
|
+
message = progname
|
26
|
+
progname = @progname
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
message = formatter.call(format_severity(severity), progname, message)
|
31
|
+
|
32
|
+
Systemd::Journal.print(log_level_map[severity], message)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def log_level_map
|
38
|
+
@log_level_map ||= {
|
39
|
+
Logger::UNKNOWN => Systemd::Journal::LOG_ALERT,
|
40
|
+
Logger::FATAL => Systemd::Journal::LOG_CRIT,
|
41
|
+
Logger::ERROR => Systemd::Journal::LOG_ERR,
|
42
|
+
Logger::WARN => Systemd::Journal::LOG_WARNING,
|
43
|
+
Logger::INFO => Systemd::Journal::LOG_INFO,
|
44
|
+
Logger::DEBUG => Systemd::Journal::LOG_DEBUG,
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
class Formatter < Base::Formatter
|
49
|
+
def call(severity, progname, msg)
|
50
|
+
msg = prefix_task_id(msg2str(msg)).truncate(Base::MAX_LOG_LINE_LENGTH)
|
51
|
+
"%5s -- %s: %s\n" % [severity, progname, msg]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/manageiq-loggers.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_runtime_dependency "activesupport", ">= 5.0"
|
25
25
|
spec.add_runtime_dependency "manageiq-password", "~> 0.1"
|
26
26
|
|
27
|
-
spec.add_development_dependency "bundler"
|
27
|
+
spec.add_development_dependency "bundler"
|
28
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
29
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
30
30
|
spec.add_development_dependency "simplecov"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manageiq-loggers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ManageIQ Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,7 +117,9 @@ files:
|
|
117
117
|
- lib/manageiq-loggers.rb
|
118
118
|
- lib/manageiq/loggers.rb
|
119
119
|
- lib/manageiq/loggers/base.rb
|
120
|
+
- lib/manageiq/loggers/cloud_watch.rb
|
120
121
|
- lib/manageiq/loggers/container.rb
|
122
|
+
- lib/manageiq/loggers/journald.rb
|
121
123
|
- lib/manageiq/loggers/version.rb
|
122
124
|
- manageiq-loggers.gemspec
|
123
125
|
homepage: https://github.com/ManageIQ/manageiq-loggers
|