manageiq-loggers 0.6.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +7 -4
- data/.rubocop.yml +3 -2
- data/.rubocop_cc.yml +3 -3
- data/.travis.yml +4 -2
- data/CHANGELOG.md +33 -3
- data/README.md +2 -2
- data/lib/manageiq/loggers/base.rb +26 -5
- data/lib/manageiq/loggers/cloud_watch.rb +1 -0
- data/lib/manageiq/loggers/container.rb +6 -5
- data/lib/manageiq/loggers/journald.rb +3 -7
- data/lib/manageiq/loggers/version.rb +1 -1
- data/lib/manageiq/loggers.rb +1 -0
- data/manageiq-loggers.gemspec +2 -1
- metadata +26 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d411d75a73f5d47de3de8080101e168c99265168eb34beef036a173955aa9823
|
4
|
+
data.tar.gz: '06163649ad33e5964c5d06f3ab369a1fa0e2fd9cf08d71ca70d0a14da6978420'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84de0b21346b0bc7d805ee5987e6575eee4e7f2b405dea90454d5f41443b0b9ec80282fad209c26b3dbd63f9d69c18159eae5e65b1aac7f3722adf1685da6358
|
7
|
+
data.tar.gz: 52d917bf352a7df54e4993d043a7b9dd1f53e79f4c55456759dc3e850f9d66e30c49fb40cfa90e5b293099a00e03600cbb6ff11e0cc9ed82370a7ee94f4d592e
|
data/.codeclimate.yml
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
-
---
|
2
1
|
version: '2'
|
3
2
|
prepare:
|
4
3
|
fetch:
|
5
|
-
- url: https://raw.githubusercontent.com/ManageIQ/
|
4
|
+
- url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_base.yml
|
6
5
|
path: ".rubocop_base.yml"
|
7
|
-
- url: https://raw.githubusercontent.com/ManageIQ/
|
6
|
+
- url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_cc_base.yml
|
8
7
|
path: ".rubocop_cc_base.yml"
|
8
|
+
- url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/styles/base.yml
|
9
|
+
path: styles/base.yml
|
10
|
+
- url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/styles/cc_base.yml
|
11
|
+
path: styles/cc_base.yml
|
9
12
|
checks:
|
10
13
|
argument-count:
|
11
14
|
enabled: false
|
@@ -28,4 +31,4 @@ plugins:
|
|
28
31
|
rubocop:
|
29
32
|
enabled: true
|
30
33
|
config: ".rubocop_cc.yml"
|
31
|
-
channel:
|
34
|
+
channel: rubocop-0-82
|
data/.rubocop.yml
CHANGED
data/.rubocop_cc.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
inherit_from:
|
2
|
-
- .rubocop_base.yml
|
3
|
-
- .rubocop_cc_base.yml
|
4
|
-
- .rubocop_local.yml
|
2
|
+
- ".rubocop_base.yml"
|
3
|
+
- ".rubocop_cc_base.yml"
|
4
|
+
- ".rubocop_local.yml"
|
data/.travis.yml
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
---
|
2
2
|
language: ruby
|
3
|
+
dist: bionic
|
3
4
|
cache: bundler
|
4
5
|
rvm:
|
5
|
-
- 2.
|
6
|
-
- 2.
|
6
|
+
- 2.6.8
|
7
|
+
- 2.7.4
|
8
|
+
- 3.0.2
|
7
9
|
before_script:
|
8
10
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
9
11
|
- chmod +x ./cc-test-reporter
|
data/CHANGELOG.md
CHANGED
@@ -5,13 +5,39 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [1.0.1] - 2021-01-05
|
9
|
+
### Fixed
|
10
|
+
- Fix require issue when used with Rails 7 [(#42)](https://github.com/ManageIQ/manageiq-loggers/pull/42)
|
11
|
+
- Check if the global is defined before trying to use it for Ruby 3 support [(#41)](https://github.com/ManageIQ/manageiq-loggers/pull/41)
|
12
|
+
|
13
|
+
## [1.0.0] - 2021-11-16
|
14
|
+
### Removed
|
15
|
+
- **BREAKING** Remove support for Ruby 2.4 and 2.5 [(#40)](https://github.com/ManageIQ/manageiq-loggers/pull/40)
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
- Fixed Ruby 3 support with kwargs [(#40)](https://github.com/ManageIQ/manageiq-loggers/pull/40)
|
19
|
+
|
20
|
+
## [0.8.0] - 2021-11-15
|
21
|
+
### Changed
|
22
|
+
- Add Ruby 2.6, 2.7, and 3.0 support [(#38)](https://github.com/ManageIQ/manageiq-loggers/pull/38)
|
23
|
+
- Add ability to set class-level and instance-level filters for log_hashes [(#38)](https://github.com/ManageIQ/manageiq-loggers/pull/38)
|
24
|
+
|
25
|
+
## [0.7.0] - 2021-09-21
|
26
|
+
### Changed
|
27
|
+
- Truncate log lines to 8Kb [(#32)](https://github.com/ManageIQ/manageiq-loggers/pull/32)
|
28
|
+
- Honor container log level [(#35)](https://github.com/ManageIQ/manageiq-loggers/pull/35)
|
29
|
+
- Use progname rather than syslog_identifier for journald logs [(#36)](https://github.com/ManageIQ/manageiq-loggers/pull/36)
|
30
|
+
|
31
|
+
### Fixed
|
32
|
+
- Handle Unicode characters in binary messages. [(#34)](https://github.com/ManageIQ/manageiq-loggers/pull/34)
|
33
|
+
|
8
34
|
## [0.6.0] - 2020-12-09
|
9
35
|
### Changed
|
10
36
|
- Update rake dependency to address CVE-2020-8130 [(#19)](https://github.com/ManageIQ/manageiq-loggers/pull/19)
|
11
37
|
|
12
38
|
### Fixed
|
13
|
-
- Fix escaping of < and > in Container logger
|
14
|
-
- Fix ActiveSupport::Deprecation call
|
39
|
+
- Fix escaping of < and > in Container logger [(#29)](https://github.com/ManageIQ/manageiq-loggers/pull/29)
|
40
|
+
- Fix ActiveSupport::Deprecation call [(#29)](https://github.com/ManageIQ/manageiq-loggers/pull/29)
|
15
41
|
- Fix the handling of journald code_file/code_line [(#21)](https://github.com/ManageIQ/manageiq-loggers/pull/21) [(#22)](https://github.com/ManageIQ/manageiq-loggers/pull/22)
|
16
42
|
|
17
43
|
### Added
|
@@ -49,7 +75,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
49
75
|
|
50
76
|
## [0.1.0] - 2019-01-08
|
51
77
|
|
52
|
-
[Unreleased]: https://github.com/ManageIQ/manageiq-loggers/compare/
|
78
|
+
[Unreleased]: https://github.com/ManageIQ/manageiq-loggers/compare/v1.0.1...master
|
79
|
+
[1.0.1]: https://github.com/ManageIQ/manageiq-loggers/compare/v1.0.0...v1.0.1
|
80
|
+
[1.0.0]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.8.0...v1.0.0
|
81
|
+
[0.8.0]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.7.0...v0.8.0
|
82
|
+
[0.7.0]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.6.0...v0.7.0
|
53
83
|
[0.6.0]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.5.0...v0.6.0
|
54
84
|
[0.5.0]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.4.2...v0.5.0
|
55
85
|
[0.4.2]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.4.1...v0.4.2
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ManageIQ::Loggers
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.
|
3
|
+
[![Build Status](https://app.travis-ci.com/ManageIQ/manageiq-loggers.svg?branch=master)](https://app.travis-ci.com/ManageIQ/manageiq-loggers)
|
4
4
|
[![Maintainability](https://api.codeclimate.com/v1/badges/8d3c9bf77c45a024166b/maintainability)](https://codeclimate.com/github/ManageIQ/manageiq-loggers/maintainability)
|
5
5
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/8d3c9bf77c45a024166b/test_coverage)](https://codeclimate.com/github/ManageIQ/manageiq-loggers/test_coverage)
|
6
6
|
[![Security](https://hakiri.io/github/ManageIQ/manageiq-loggers/master.svg)](https://hakiri.io/github/ManageIQ/manageiq-loggers/master)
|
@@ -39,7 +39,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
39
39
|
|
40
40
|
## Contributing
|
41
41
|
|
42
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
42
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ManageIQ/manageiq-loggers.
|
43
43
|
|
44
44
|
## License
|
45
45
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'logger'
|
2
|
+
require 'active_support'
|
2
3
|
require 'active_support/core_ext/object/try'
|
3
4
|
require 'active_support/core_ext/numeric/bytes'
|
4
5
|
require 'active_support/core_ext/string'
|
@@ -7,9 +8,9 @@ require 'English'
|
|
7
8
|
module ManageIQ
|
8
9
|
module Loggers
|
9
10
|
class Base < Logger
|
10
|
-
MAX_LOG_LINE_LENGTH =
|
11
|
+
MAX_LOG_LINE_LENGTH = 8.kilobytes
|
11
12
|
|
12
|
-
def initialize(*
|
13
|
+
def initialize(*_, **_)
|
13
14
|
super
|
14
15
|
self.level = INFO
|
15
16
|
|
@@ -72,13 +73,24 @@ module ManageIQ
|
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
76
|
+
private_class_method def self.clean_log_hashes_filter(filters)
|
77
|
+
(Array(filters).compact.map(&:to_s) << "password").uniq
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.log_hashes_filter
|
81
|
+
@log_hashes_filter ||= ["password"]
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.log_hashes_filter=(filters)
|
85
|
+
@log_hashes_filter = clean_log_hashes_filter(filters)
|
86
|
+
end
|
87
|
+
|
75
88
|
def self.log_hashes(logger, h, options = {})
|
76
89
|
require 'yaml'
|
77
90
|
require 'manageiq/password'
|
78
91
|
|
79
92
|
level = options[:log_level] || :info
|
80
|
-
filter =
|
81
|
-
filter.uniq!
|
93
|
+
filter = options[:filter] ? clean_log_hashes_filter(options[:filter]) : log_hashes_filter
|
82
94
|
|
83
95
|
values = YAML.dump(h.to_hash).gsub(ManageIQ::Password::REGEXP, "[FILTERED]")
|
84
96
|
values = values.split("\n").map do |l|
|
@@ -91,7 +103,16 @@ module ManageIQ
|
|
91
103
|
logger.send(level, "\n#{values}")
|
92
104
|
end
|
93
105
|
|
106
|
+
def log_hashes_filter
|
107
|
+
@log_hashes_filter || self.class.log_hashes_filter
|
108
|
+
end
|
109
|
+
|
110
|
+
def log_hashes_filter=(filters)
|
111
|
+
@log_hashes_filter = self.class.send(:clean_log_hashes_filter, filters)
|
112
|
+
end
|
113
|
+
|
94
114
|
def log_hashes(h, options = {})
|
115
|
+
options[:filter] ||= log_hashes_filter
|
95
116
|
self.class.log_hashes(self, h, options)
|
96
117
|
end
|
97
118
|
|
@@ -131,7 +152,7 @@ module ManageIQ
|
|
131
152
|
|
132
153
|
def prefix_task_id(msg)
|
133
154
|
# Add task id to the message if a task is currently being worked on.
|
134
|
-
if (task_id = (Thread.current["tracking_label"] || $_miq_worker_current_msg.try(:task_id)))
|
155
|
+
if (task_id = (Thread.current["tracking_label"] || (defined?($_miq_worker_current_msg) && $_miq_worker_current_msg.try(:task_id))))
|
135
156
|
prefix = "Q-task_id([#{task_id}])"
|
136
157
|
msg = "#{prefix} #{msg}" unless msg.include?(prefix)
|
137
158
|
end
|
@@ -5,12 +5,8 @@ module ManageIQ
|
|
5
5
|
logdev.sync = true # Don't buffer container log output
|
6
6
|
|
7
7
|
super
|
8
|
-
self.level = DEBUG
|
9
|
-
self.formatter = Formatter.new
|
10
|
-
end
|
11
8
|
|
12
|
-
|
13
|
-
super(DEBUG) # We want everything written to the ContainerLogger written to STDOUT
|
9
|
+
self.formatter = Formatter.new
|
14
10
|
end
|
15
11
|
|
16
12
|
def filename
|
@@ -48,6 +44,11 @@ module ManageIQ
|
|
48
44
|
# :tags => "tags string",
|
49
45
|
}.compact
|
50
46
|
JSON.generate(payload) << "\n"
|
47
|
+
rescue Encoding::UndefinedConversionError
|
48
|
+
raise unless msg.encoding == Encoding::ASCII_8BIT
|
49
|
+
|
50
|
+
msg.force_encoding("UTF-8")
|
51
|
+
retry
|
51
52
|
end
|
52
53
|
|
53
54
|
private
|
@@ -1,21 +1,17 @@
|
|
1
1
|
module ManageIQ
|
2
2
|
module Loggers
|
3
3
|
class Journald < Base
|
4
|
-
# An syslog identifier used when writing messages. The default is the progname.
|
5
|
-
attr_accessor :syslog_identifier
|
6
|
-
|
7
4
|
# Create and return a new ManageIQ::Loggers::Journald instance. The
|
8
5
|
# arguments to the initializer can be ignored unless you're multicasting.
|
9
6
|
#
|
10
7
|
# Internally we set our own formatter, and automatically set the
|
11
8
|
# progname option to 'manageiq' if not specified.
|
12
9
|
#
|
13
|
-
def initialize(
|
10
|
+
def initialize(_logdev = nil, *_, **_)
|
14
11
|
require "systemd-journal"
|
15
|
-
super
|
12
|
+
super
|
16
13
|
@formatter = Formatter.new
|
17
14
|
@progname ||= 'manageiq'
|
18
|
-
@syslog_identifier ||= @progname
|
19
15
|
end
|
20
16
|
|
21
17
|
# Comply with the VMDB::Logger interface. For a filename we simply use
|
@@ -49,7 +45,7 @@ module ManageIQ
|
|
49
45
|
Systemd::Journal.message(
|
50
46
|
:message => message,
|
51
47
|
:priority => log_level_map[severity],
|
52
|
-
:syslog_identifier =>
|
48
|
+
:syslog_identifier => progname,
|
53
49
|
:code_line => caller_object.lineno,
|
54
50
|
:code_file => caller_object.absolute_path,
|
55
51
|
:code_func => caller_object.label
|
data/lib/manageiq/loggers.rb
CHANGED
data/manageiq-loggers.gemspec
CHANGED
@@ -23,10 +23,11 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
25
|
spec.add_runtime_dependency "activesupport", ">= 5.0"
|
26
|
-
spec.add_runtime_dependency "manageiq-password", "
|
26
|
+
spec.add_runtime_dependency "manageiq-password", "< 2"
|
27
27
|
|
28
28
|
spec.add_development_dependency "bundler"
|
29
29
|
spec.add_development_dependency "cloudwatchlogger"
|
30
|
+
spec.add_development_dependency "manageiq-style"
|
30
31
|
spec.add_development_dependency "rake", ">= 12.3.3"
|
31
32
|
spec.add_development_dependency "rspec", "~> 3.0"
|
32
33
|
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: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ManageIQ Authors
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: manageiq-password
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "<"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,49 +67,49 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: manageiq-style
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 12.3.3
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 12.3.3
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
103
|
+
version: '3.0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
110
|
+
version: '3.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: simplecov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -122,8 +122,8 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
description:
|
126
|
-
email:
|
125
|
+
description:
|
126
|
+
email:
|
127
127
|
executables: []
|
128
128
|
extensions: []
|
129
129
|
extra_rdoc_files: []
|
@@ -154,7 +154,7 @@ homepage: https://github.com/ManageIQ/manageiq-loggers
|
|
154
154
|
licenses:
|
155
155
|
- Apache-2.0
|
156
156
|
metadata: {}
|
157
|
-
post_install_message:
|
157
|
+
post_install_message:
|
158
158
|
rdoc_options: []
|
159
159
|
require_paths:
|
160
160
|
- lib
|
@@ -169,8 +169,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
169
|
- !ruby/object:Gem::Version
|
170
170
|
version: '0'
|
171
171
|
requirements: []
|
172
|
-
rubygems_version: 3.
|
173
|
-
signing_key:
|
172
|
+
rubygems_version: 3.1.6
|
173
|
+
signing_key:
|
174
174
|
specification_version: 4
|
175
175
|
summary: Loggers for ManageIQ projects
|
176
176
|
test_files: []
|