manageiq-loggers 0.5.0 → 1.0.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: 2dcf2285622bf4c8e99e5f51bfa285cd730ad63ecf2c99ba3d415935b9b4232b
4
- data.tar.gz: 40f8ea813b609c2c4c51da5119d8d5d941ddc06983d677c28a97d965ec7174b0
3
+ metadata.gz: a3eb7ea1a06988309ad93d51e5be24deb9f9252621e35816d3a746a2aaaa2147
4
+ data.tar.gz: 725ba6fe5040b59543e69b5005257a0b2caa336cb882f7db7baa581c9e6a1e95
5
5
  SHA512:
6
- metadata.gz: 8548fb479e0c8a465d6afc6b97dae2fbd5b5079a7fbfa9112e59ff5b003de6f34e35f748babf67c7a8828cb45d2143237a5f0b6439d37c0ae2cc1959398f3128
7
- data.tar.gz: e217e0699b90729596661de7a1f9c751560305cb7509f80f8c23ebc487a74ca2c1e40070f272e016872593e5a441888515a4adf6fea00fcee7a99ae14b5fb988
6
+ metadata.gz: 978b7049328f4e775e7d622de15a42737a5e6141c00565282767ea9f637cab8d0ce234feb45adbc184db86b3e4f20a683be1aca895bfd394d8ccc76f9b0d07b6
7
+ data.tar.gz: 2ba937fb168cecc740263eab132ff60469261deadddf4b6006ae3f6871d8d2bbc0b91a0adff503bdeb403def7363917fe5a9349e73d4e166433d030d112e8d77
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/guides/master/.rubocop_base.yml
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/guides/master/.rubocop_cc_base.yml
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: 'rubocop-0-69'
34
+ channel: rubocop-0-82
data/.rubocop.yml CHANGED
@@ -1,3 +1,4 @@
1
1
  inherit_from:
2
- - https://raw.githubusercontent.com/ManageIQ/guides/master/.rubocop_base.yml
3
- - .rubocop_local.yml
2
+ - ".rubocop_local.yml"
3
+ inherit_gem:
4
+ manageiq-style: ".rubocop_base.yml"
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,10 +1,11 @@
1
1
  ---
2
2
  language: ruby
3
- sudo: false
3
+ dist: bionic
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.4.5
7
- - 2.5.3
6
+ - 2.6.8
7
+ - 2.7.4
8
+ - 3.0.2
8
9
  before_script:
9
10
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
10
11
  - chmod +x ./cc-test-reporter
data/CHANGELOG.md CHANGED
@@ -5,6 +5,39 @@ This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [1.0.0] - 2021-11-16
9
+ ### Removed
10
+ - **BREAKING** Remove support for Ruby 2.4 and 2.5 [(#40)](https://github.com/ManageIQ/manageiq-loggers/pull/40)
11
+
12
+ ### Fixed
13
+ - Fixed Ruby 3 support with kwargs [(#40)](https://github.com/ManageIQ/manageiq-loggers/pull/40)
14
+
15
+ ## [0.8.0] - 2021-11-15
16
+ ### Changed
17
+ - Add Ruby 2.6, 2.7, and 3.0 support [(#38)](https://github.com/ManageIQ/manageiq-loggers/pull/38)
18
+ - Add ability to set class-level and instance-level filters for log_hashes [(#38)](https://github.com/ManageIQ/manageiq-loggers/pull/38)
19
+
20
+ ## [0.7.0] - 2021-09-21
21
+ ### Changed
22
+ - Truncate log lines to 8Kb [(#32)](https://github.com/ManageIQ/manageiq-loggers/pull/32)
23
+ - Honor container log level [(#35)](https://github.com/ManageIQ/manageiq-loggers/pull/35)
24
+ - Use progname rather than syslog_identifier for journald logs [(#36)](https://github.com/ManageIQ/manageiq-loggers/pull/36)
25
+
26
+ ### Fixed
27
+ - Handle Unicode characters in binary messages. [(#34)](https://github.com/ManageIQ/manageiq-loggers/pull/34)
28
+
29
+ ## [0.6.0] - 2020-12-09
30
+ ### Changed
31
+ - Update rake dependency to address CVE-2020-8130 [(#19)](https://github.com/ManageIQ/manageiq-loggers/pull/19)
32
+
33
+ ### Fixed
34
+ - Fix escaping of < and > in Container logger [(#29)](https://github.com/ManageIQ/manageiq-loggers/pull/29)
35
+ - Fix ActiveSupport::Deprecation call [(#29)](https://github.com/ManageIQ/manageiq-loggers/pull/29)
36
+ - 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)
37
+
38
+ ### Added
39
+ - Add code_func to the journald logger [(#23)](https://github.com/ManageIQ/manageiq-loggers/pull/23)
40
+
8
41
  ## [0.5.0] - 2020-03-18
9
42
  ### Changed
10
43
  - Deprecate Thread.current[:current_request]&.request_id in favor of Thread.current[:request_id] [(#17)](https://github.com/ManageIQ/manageiq-loggers/pull/17)
@@ -37,7 +70,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
37
70
 
38
71
  ## [0.1.0] - 2019-01-08
39
72
 
40
- [Unreleased]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.5.0...master
73
+ [Unreleased]: https://github.com/ManageIQ/manageiq-loggers/compare/v1.0.0...master
74
+ [0.8.0]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.8.0...v1.0.0
75
+ [0.8.0]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.7.0...v0.8.0
76
+ [0.7.0]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.6.0...v0.7.0
77
+ [0.6.0]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.5.0...v0.6.0
41
78
  [0.5.0]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.4.2...v0.5.0
42
79
  [0.4.2]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.4.1...v0.4.2
43
80
  [0.4.1]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.4.0...v0.4.1
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ManageIQ::Loggers
2
2
 
3
- [![Build Status](https://travis-ci.org/ManageIQ/manageiq-loggers.svg)](https://travis-ci.org/ManageIQ/manageiq-loggers)
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/[USERNAME]/manageiq-loggers.
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ManageIQ/manageiq-loggers.
43
43
 
44
44
  ## License
45
45
 
@@ -7,9 +7,9 @@ require 'English'
7
7
  module ManageIQ
8
8
  module Loggers
9
9
  class Base < Logger
10
- MAX_LOG_LINE_LENGTH = 1.megabyte
10
+ MAX_LOG_LINE_LENGTH = 8.kilobytes
11
11
 
12
- def initialize(*args)
12
+ def initialize(*_, **_)
13
13
  super
14
14
  self.level = INFO
15
15
 
@@ -72,13 +72,24 @@ module ManageIQ
72
72
  end
73
73
  end
74
74
 
75
+ private_class_method def self.clean_log_hashes_filter(filters)
76
+ (Array(filters).compact.map(&:to_s) << "password").uniq
77
+ end
78
+
79
+ def self.log_hashes_filter
80
+ @log_hashes_filter ||= ["password"]
81
+ end
82
+
83
+ def self.log_hashes_filter=(filters)
84
+ @log_hashes_filter = clean_log_hashes_filter(filters)
85
+ end
86
+
75
87
  def self.log_hashes(logger, h, options = {})
76
88
  require 'yaml'
77
89
  require 'manageiq/password'
78
90
 
79
91
  level = options[:log_level] || :info
80
- filter = Array(options[:filter]).flatten.compact.map(&:to_s) << "password"
81
- filter.uniq!
92
+ filter = options[:filter] ? clean_log_hashes_filter(options[:filter]) : log_hashes_filter
82
93
 
83
94
  values = YAML.dump(h.to_hash).gsub(ManageIQ::Password::REGEXP, "[FILTERED]")
84
95
  values = values.split("\n").map do |l|
@@ -91,7 +102,16 @@ module ManageIQ
91
102
  logger.send(level, "\n#{values}")
92
103
  end
93
104
 
105
+ def log_hashes_filter
106
+ @log_hashes_filter || self.class.log_hashes_filter
107
+ end
108
+
109
+ def log_hashes_filter=(filters)
110
+ @log_hashes_filter = self.class.send(:clean_log_hashes_filter, filters)
111
+ end
112
+
94
113
  def log_hashes(h, options = {})
114
+ options[:filter] ||= log_hashes_filter
95
115
  self.class.log_hashes(self, h, options)
96
116
  end
97
117
 
@@ -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
- def level=(_new_level)
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
@@ -36,7 +32,7 @@ module ManageIQ
36
32
  def call(severity, time, progname, msg)
37
33
  # From https://github.com/ViaQ/elasticsearch-templates/releases -> Downloads -> *.asciidoc
38
34
  # NOTE: These values are in a specific order for easier human readbility via STDOUT
39
- {
35
+ payload = {
40
36
  :@timestamp => format_datetime(time),
41
37
  :hostname => hostname,
42
38
  :pid => $PROCESS_ID,
@@ -46,7 +42,13 @@ module ManageIQ
46
42
  :message => prefix_task_id(msg2str(msg)),
47
43
  :request_id => request_id
48
44
  # :tags => "tags string",
49
- }.compact.to_json << "\n"
45
+ }.compact
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
50
52
  end
51
53
 
52
54
  private
@@ -64,11 +66,12 @@ module ManageIQ
64
66
  end
65
67
 
66
68
  def request_id
67
- if Thread.current[:current_request]&.request_id
68
- ActiveSupport::Deprecation.warn("Usage of `Thread.current[:current_request]&.request_id` will be deprecated in version 0.5.0. Please switch to `Thread.current[:request_id]` to log request_id automatically.")
69
+ Thread.current[:request_id] || Thread.current[:current_request]&.request_id.tap do |request_id|
70
+ if request_id
71
+ require "active_support/deprecation"
72
+ ActiveSupport::Deprecation.warn("Usage of `Thread.current[:current_request]&.request_id` will be deprecated in version 0.5.0. Please switch to `Thread.current[:request_id]` to log request_id automatically.")
73
+ end
69
74
  end
70
-
71
- Thread.current[:current_request]&.request_id || Thread.current[:request_id]
72
75
  end
73
76
  end
74
77
  end
@@ -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(logdev = nil, *args)
10
+ def initialize(_logdev = nil, *_, **_)
14
11
  require "systemd-journal"
15
- super(logdev, *args)
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
@@ -44,14 +40,15 @@ module ManageIQ
44
40
  end
45
41
 
46
42
  message = formatter.call(format_severity(severity), progname, message)
47
- caller_object = caller_locations.last
43
+ caller_object = caller_locations(3, 1).first
48
44
 
49
45
  Systemd::Journal.message(
50
46
  :message => message,
51
47
  :priority => log_level_map[severity],
52
- :syslog_identifier => syslog_identifier,
48
+ :syslog_identifier => progname,
53
49
  :code_line => caller_object.lineno,
54
- :code_file => caller_object.absolute_path
50
+ :code_file => caller_object.absolute_path,
51
+ :code_func => caller_object.label
55
52
  )
56
53
  end
57
54
 
@@ -1,5 +1,5 @@
1
1
  module ManageIQ
2
2
  module Loggers
3
- VERSION = "0.5.0".freeze
3
+ VERSION = "1.0.0".freeze
4
4
  end
5
5
  end
@@ -1,4 +1,5 @@
1
1
  require "manageiq/loggers/base"
2
2
  require "manageiq/loggers/cloud_watch"
3
3
  require "manageiq/loggers/container"
4
+ require "manageiq/loggers/journald"
4
5
  require "manageiq/loggers/version"
@@ -23,11 +23,12 @@ 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", "~> 0.1"
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 "rake", "~> 10.0"
30
+ spec.add_development_dependency "manageiq-style"
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"
33
34
  spec.add_development_dependency "systemd-journal" if RbConfig::CONFIG['host_os'] =~ /linux/i
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.5.0
4
+ version: 1.0.0
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: 2020-03-18 00:00:00.000000000 Z
11
+ date: 2021-11-16 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: '0.1'
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: '0.1'
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: rake
70
+ name: manageiq-style
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
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: '10.0'
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rspec
84
+ name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '3.0'
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: '3.0'
96
+ version: 12.3.3
97
97
  - !ruby/object:Gem::Dependency
98
- name: simplecov
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: systemd-journal
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.0.6
173
- signing_key:
172
+ rubygems_version: 3.2.22
173
+ signing_key:
174
174
  specification_version: 4
175
175
  summary: Loggers for ManageIQ projects
176
176
  test_files: []