manageiq-loggers 0.4.0 → 0.4.1

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: c5773ad03d0c3eed3c6751ff24a39f7ca8fc8a48db9f1d26d7b302296af63d73
4
- data.tar.gz: 062b8d65c09a5d9b3fa0743b47d647c2b892933e3c22d23937afa2fa7b5c951a
3
+ metadata.gz: f43cbf53e58f32f3e270f87d248dbf379a0d779be61ec33e72d8ee6f028a265d
4
+ data.tar.gz: a9dee3b993cef7a02617608887092ace4a7dd4aa0b4e79390225ce5311d485c5
5
5
  SHA512:
6
- metadata.gz: 66da0f4850139bd628f2919153e036f4a8c8401d8b733a6b761396d8898bd3ec0b919f6762dc57de8a89b9aaa8e945413a622365a0fe72d194399d6886de90ad
7
- data.tar.gz: 5b03f2ba30b1ca8aac3a472b02b1cc1bde1be43e3052b21ea81ce1aa4d81877f68ebb4d199af322cd507f359ed7f4bd268af196a3b1ea8e8e73068968201757c
6
+ metadata.gz: 5140757154082052608cb7e0d60fb902d186ff16c917217ac1a574e2ee9c199d4339e06bc8d0664d54b587c84416496d7a98f8439720e38ab2f1d3697a97fc52
7
+ data.tar.gz: 8a6a0da62b87fe90889835a42c0c7077b50cb5e6714e45e9e9850b39a6343e2264ae423b802b4681dba3c355e1ada1209e80fe8bc201cc10f148bee3f1f5663e
@@ -28,3 +28,4 @@ plugins:
28
28
  rubocop:
29
29
  enabled: true
30
30
  config: ".rubocop_cc.yml"
31
+ channel: 'rubocop-0-69'
@@ -5,6 +5,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.4.1] - 2020-01-06
9
+ ### Fixed
10
+ - Change CloudWatch logger log_group and log_stream values for easier debugging and unique identifiers [(#15)](https://github.com/ManageIQ/manageiq-loggers/pull/15)
11
+ - Enhancements to the journald logger to allow for easier debugging [(#11)](https://github.com/ManageIQ/manageiq-loggers/pull/11)
12
+
8
13
  ## [0.4.0] - 2019-08-15
9
14
  ### Changed
10
15
  - The Cloud Watch logger will now also broadcast its log messages to the container logger [(#10)](https://github.com/ManageIQ/manageiq-loggers/pull/10)
@@ -24,7 +29,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
24
29
 
25
30
  ## [0.1.0] - 2019-01-08
26
31
 
27
- [Unreleased]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.4.0...master
32
+ [Unreleased]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.4.1...master
33
+ [0.4.1]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.4.0...v0.4.1
28
34
  [0.4.0]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.3.0...v0.4.0
29
35
  [0.3.0]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.2.0...v0.3.0
30
36
  [0.2.0]: https://github.com/ManageIQ/manageiq-loggers/compare/v0.1.1...v0.2.0
@@ -9,8 +9,9 @@ module ManageIQ
9
9
  def self.new(*args)
10
10
  access_key_id = ENV["CW_AWS_ACCESS_KEY_ID"].presence
11
11
  secret_access_key = ENV["CW_AWS_SECRET_ACCESS_KEY"].presence
12
- log_group_name = ENV["CLOUD_WATCH_LOG_GROUP"].presence
13
- log_stream_name = File.exist?(NAMESPACE_FILE) ? File.read(NAMESPACE_FILE) : nil
12
+ namespace = File.exist?(NAMESPACE_FILE) ? File.read(NAMESPACE_FILE) : nil
13
+ log_group_name = namespace || ENV["CLOUD_WATCH_LOG_GROUP"].presence
14
+ log_stream_name = ENV["HOSTNAME"].presence
14
15
 
15
16
  container_logger = ManageIQ::Loggers::Container.new
16
17
  return container_logger unless access_key_id && secret_access_key && log_group_name && log_stream_name
@@ -1,17 +1,33 @@
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
+ # Create and return a new ManageIQ::Loggers::Journald instance. The
8
+ # arguments to the initializer can be ignored unless you're multicasting.
9
+ #
10
+ # Internally we set our own formatter, and automatically set the
11
+ # progname option to 'manageiq' if not specified.
12
+ #
4
13
  def initialize(logdev = nil, *args)
5
14
  require "systemd-journal"
6
-
7
15
  super(logdev, *args)
8
- self.formatter = Formatter.new
16
+ @formatter = Formatter.new
17
+ @progname ||= 'manageiq'
18
+ @syslog_identifier ||= @progname
9
19
  end
10
20
 
21
+ # Comply with the VMDB::Logger interface. For a filename we simply use
22
+ # the string 'journald' since we're not using a backing file directly.
23
+ #
11
24
  def filename
12
25
  "journald"
13
26
  end
14
27
 
28
+ # Redefine this method from the core Logger class. Internally this is
29
+ # the method used when .info, .warn, etc are called.
30
+ #
15
31
  def add(severity, message = nil, progname = nil)
16
32
  severity ||= Logger::UNKNOWN
17
33
  return true if severity < @level
@@ -28,12 +44,22 @@ module ManageIQ
28
44
  end
29
45
 
30
46
  message = formatter.call(format_severity(severity), progname, message)
47
+ caller_object = caller_locations.last
31
48
 
32
- Systemd::Journal.print(log_level_map[severity], message)
49
+ Systemd::Journal.message(
50
+ :message => message,
51
+ :priority => log_level_map[severity],
52
+ :syslog_identifier => syslog_identifier,
53
+ :code_line => caller_object.lineno,
54
+ :code_file => caller_object.absolute_path
55
+ )
33
56
  end
34
57
 
35
58
  private
36
59
 
60
+ # Map the Systemd::Journal error levels to the Logger error levels. For
61
+ # unknown, we go with alert level.
62
+ #
37
63
  def log_level_map
38
64
  @log_level_map ||= {
39
65
  Logger::UNKNOWN => Systemd::Journal::LOG_ALERT,
@@ -1,5 +1,5 @@
1
- module Manageiq
1
+ module ManageIQ
2
2
  module Loggers
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1".freeze
4
4
  end
5
5
  end
@@ -2,10 +2,11 @@
2
2
  lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require "manageiq/loggers/version"
5
+ require "rbconfig"
5
6
 
6
7
  Gem::Specification.new do |spec|
7
8
  spec.name = "manageiq-loggers"
8
- spec.version = Manageiq::Loggers::VERSION
9
+ spec.version = ManageIQ::Loggers::VERSION
9
10
  spec.authors = ["ManageIQ Authors"]
10
11
 
11
12
  spec.summary = %q{Loggers for ManageIQ projects}
@@ -29,4 +30,5 @@ Gem::Specification.new do |spec|
29
30
  spec.add_development_dependency "rake", "~> 10.0"
30
31
  spec.add_development_dependency "rspec", "~> 3.0"
31
32
  spec.add_development_dependency "simplecov"
33
+ spec.add_development_dependency "systemd-journal" if RbConfig::CONFIG['host_os'] =~ /linux/i
32
34
  end
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.0
4
+ version: 0.4.1
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-08-15 00:00:00.000000000 Z
11
+ date: 2020-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: systemd-journal
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description:
112
126
  email:
113
127
  executables: []
@@ -155,8 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
169
  - !ruby/object:Gem::Version
156
170
  version: '0'
157
171
  requirements: []
158
- rubyforge_project:
159
- rubygems_version: 2.7.6.2
172
+ rubygems_version: 3.0.6
160
173
  signing_key:
161
174
  specification_version: 4
162
175
  summary: Loggers for ManageIQ projects