insights-loggers-ruby 0.1.3 → 0.1.8

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: 938cf90281c5264bf0a1e4123363f761432ee9027b758384ff879d2e612b650e
4
- data.tar.gz: 1741404c796ceb9bcf24635d2bb8a02a47bc9d449046d4724d73a941a7e971ae
3
+ metadata.gz: 1c0a7bf4aa40c070010cc494461deb0f35923c2c274e546577dfaafa9edca8a3
4
+ data.tar.gz: 0c9e52139fb119a3f740e033987a9400444d44660fe375a343361b375b3d365b
5
5
  SHA512:
6
- metadata.gz: a5988e41b87473f66cbf083002fe738872a7faa07305ee74c3c6a202c7cd43c44e9a174f80ce477dbd6ed6fb54478dc3bce3097c2dd34a7d4a8488d7af8ce3df
7
- data.tar.gz: bd0765380e5b0dfb03f3521fabcd9ff2bf59b1ebdf030516c4ce9fe6470298d88a8dc182dd613c821ff1a28bbd4c302a7b6eb2489382883f40665481d72e1f46
6
+ metadata.gz: 9e75c88eee30d67841685021d4a5234b6b6f7d15c156516d63852a86a3eb163dbf1fe039e37eecdf8f87255e2f2419895bc8d04cf4907438867e85909079748c
7
+ data.tar.gz: ed7ecdfa87390b45fef75d396249c6a2ad7a76d772e3926ac1c98ec7f34fb3a456f88d5a3d2b3c25a1ae1d174d88c7efa3db93301a4285d2c808c956805785a4
data/README.md CHANGED
@@ -25,15 +25,15 @@ Or install it yourself as:
25
25
  ### Example
26
26
  ```ruby
27
27
  require 'insights/loggers'
28
- logger_class = "Insights::Loggers::LoggingService"
29
- logger = Insights::Loggers::Base.create_logger(logger_class)
30
- logger.class #=> Insights::Loggers::LoggingService
28
+ logger_class = "Insights::Loggers::StdErrorLogger"
29
+ logger = Insights::Loggers::Factory.create_logger(logger_class)
30
+ logger.class #=> Insights::Loggers::StdErrorLogger
31
31
  logger.info("test")
32
32
  #{"@timestamp":"2021-04-28T12:56:28.682015 ","pid":11561,"tid":"3fd1d4c2ffd4","level":"info","message":"test","tags":["insights_application"],"labels":{"app":"insights_application"}}
33
33
  #^^^standard error output (it is not return value)
34
34
  #=> true
35
35
  #
36
- logger = Insights::Loggers::Base.create_logger(logger_class, {:app_name => "MyApp"})
36
+ logger = Insights::Loggers::Factory.create_logger(logger_class, {:app_name => "MyApp"})
37
37
  logger.warn("test")
38
38
  #{"@timestamp":"2021-04-28T13:31:40.311131 ","pid":11561,"tid":"3fd1d4c2ffd4","level":"warning","message":"test","tags":["MyApp"],"labels":{"app":"MyApp"}}
39
39
  #^^^standard error output
@@ -45,14 +45,14 @@ ManageIQ::Loggers::Base
45
45
  ManageIQ::Loggers::Container
46
46
  ManageIQ::Loggers::CloudWatch
47
47
  ManageIQ::Loggers::Journald
48
- Insights::Loggers::LoggingService
48
+ Insights::Loggers::StdErrorLogger
49
49
  TopologicalInventory::Providers::Common::Logger
50
50
  ```
51
51
 
52
52
  First for refers to gem `manageiq-loggers` and
53
53
  last one refers to `topological_inventory-providers-common` gem.
54
54
 
55
- `insights-loggers-ruby` adds own logger `Insights::Loggers::LoggingService`
55
+ `insights-loggers-ruby` adds own logger `Insights::Loggers::StdErrorLogger`
56
56
  which is producing log to standard error output.
57
57
  This standard error output can be consumed by [haberdasher](https://github.com/RedHatInsights/haberdasher) tool.
58
58
 
@@ -61,18 +61,18 @@ This standard error output can be consumed by [haberdasher](https://github.com/R
61
61
  Logger object can be built with method:
62
62
 
63
63
  ```
64
- Insights::Loggers::Base.create_logger
64
+ Insights::Loggers::Factory.create_logger
65
65
  ```
66
66
  First parameter is `logger_class` and second parameter is
67
67
  hash with parameters.
68
68
  Supported hash parameters are:
69
69
 
70
70
  - `:log_path` - required for `ManageIQ::Loggers::Base` logger, it specifies the path to log file
71
- - `:app_name` - applicable for `Insights::Loggers::LoggingService`, it specifies the tags and labels values in formatted output
71
+ - `:app_name` - applicable for `Insights::Loggers::StdErrorLogger`, it specifies the tags and labels values in formatted output
72
72
 
73
- ### Formatted output for `Insights::Loggers::LoggingService` logger
73
+ ### Formatted output for `Insights::Loggers::StdErrorLogger` logger
74
74
 
75
- Logging service produces formatted output:
75
+ Standard error logger produces formatted output:
76
76
 
77
77
  ```
78
78
  {"@timestamp":"2021-04-28T13:31:40.311131 ",
@@ -91,7 +91,7 @@ when app_name is not set in hash parameters.
91
91
 
92
92
  ## Dependencies
93
93
 
94
- Logging service inherits from `ManageIQ::Loggers::Container` class and
94
+ Standard error logger inherits from `ManageIQ::Loggers::Container` class and
95
95
  thanks to that `manageiq-loggers` is required dependency.
96
96
 
97
97
  Usage other loggers is possible also from `manageiq-loggers` gem.
@@ -22,11 +22,11 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.add_runtime_dependency "activesupport", "~> 5.0"
26
- spec.add_runtime_dependency "topological_inventory-providers-common", "~> 2.1.5"
25
+ spec.add_runtime_dependency "activesupport", "~> 5.2", ">= 5.2.4.3"
26
+ spec.add_runtime_dependency "topological_inventory-providers-common", "~> 3.0.1"
27
27
  spec.add_runtime_dependency "manageiq-loggers", "~> 0.4", ">= 0.4.2"
28
28
 
29
- spec.add_runtime_dependency "cloudwatchlogger", "~> 0.3.0"
29
+ spec.add_runtime_dependency "cloudwatchlogger", "~> 0.2.1"
30
30
  spec.add_development_dependency "manageiq-style", "~> 1.3.0"
31
31
  spec.add_development_dependency "rake", "~> 12.3", ">= 12.3.3"
32
32
  spec.add_development_dependency "rspec", "~> 3.0"
@@ -1,2 +1,2 @@
1
1
  require "insights/loggers/version"
2
- require "insights/loggers/base"
2
+ require "insights/loggers/factory"
@@ -1,8 +1,8 @@
1
1
  module Insights
2
2
  module Loggers
3
- class Base
3
+ class Factory
4
4
  def self.create_logger(logger_class, args = nil)
5
- logger_library_loader(logger_class)
5
+ logger_library_loader(logger_class, args)
6
6
  klass = logger_class.safe_constantize
7
7
 
8
8
  if klass
@@ -23,10 +23,18 @@ module Insights
23
23
  logger.app_name_for_formatter(args[:app_name])
24
24
  end
25
25
 
26
+ if args && args[:extend_module]
27
+ logger.extend(args[:extend_module].safe_constantize)
28
+ end
29
+
26
30
  logger
27
31
  end
28
32
 
29
- private_class_method def self.logger_library_loader(logger_class)
33
+ EXTENDED_LIBRARY_FROM_MODULE = {
34
+ "TopologicalInventory::Providers::Common::LoggingFunctions" => "topological_inventory/providers/common/logging"
35
+ }.freeze
36
+
37
+ private_class_method def self.logger_library_loader(logger_class, args = nil)
30
38
  case logger_class
31
39
  when "ManageIQ::Loggers::Base"
32
40
  require "manageiq/loggers/base"
@@ -44,10 +52,16 @@ module Insights
44
52
 
45
53
  require "manageiq/loggers/base"
46
54
  require "manageiq/loggers/journald"
47
- when "Insights::Loggers::LoggingService"
55
+ when "Insights::Loggers::StdErrorLogger"
48
56
  require "manageiq/loggers/base"
49
57
  require "manageiq/loggers/container"
50
- require "insights/loggers/logging_service"
58
+ require "insights/loggers/std_error_logger"
59
+ if args && args[:extend_module]
60
+ library_path = EXTENDED_LIBRARY_FROM_MODULE[args[:extend_module]]
61
+ raise ArgumentError, "Unable to find library for #{args[:extend_module]}" unless library_path
62
+
63
+ require EXTENDED_LIBRARY_FROM_MODULE[args[:extend_module]]
64
+ end
51
65
  when "TopologicalInventory::Providers::Common::Logger"
52
66
  require "topological_inventory/providers/common/logging"
53
67
  else
@@ -1,6 +1,6 @@
1
1
  module Insights
2
2
  module Loggers
3
- class LoggingService < ManageIQ::Loggers::Container
3
+ class StdErrorLogger < ManageIQ::Loggers::Container
4
4
  def initialize(*args)
5
5
  super
6
6
  self.reopen(STDERR)
@@ -1,5 +1,5 @@
1
1
  module Insights
2
2
  module Loggers
3
- VERSION = "0.1.3".freeze
3
+ VERSION = "0.1.8".freeze
4
4
  end
5
5
  end
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.3
4
+ version: 0.1.8
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-04-29 00:00:00.000000000 Z
11
+ date: 2021-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,28 +16,34 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: '5.2'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 5.2.4.3
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '5.0'
29
+ version: '5.2'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.2.4.3
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: topological_inventory-providers-common
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: 2.1.5
39
+ version: 3.0.1
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
44
  - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: 2.1.5
46
+ version: 3.0.1
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: manageiq-loggers
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -64,14 +70,14 @@ dependencies:
64
70
  requirements:
65
71
  - - "~>"
66
72
  - !ruby/object:Gem::Version
67
- version: 0.3.0
73
+ version: 0.2.1
68
74
  type: :runtime
69
75
  prerelease: false
70
76
  version_requirements: !ruby/object:Gem::Requirement
71
77
  requirements:
72
78
  - - "~>"
73
79
  - !ruby/object:Gem::Version
74
- version: 0.3.0
80
+ version: 0.2.1
75
81
  - !ruby/object:Gem::Dependency
76
82
  name: manageiq-style
77
83
  requirement: !ruby/object:Gem::Requirement
@@ -172,8 +178,8 @@ files:
172
178
  - insights-loggers-ruby.gemspec
173
179
  - lib/insights-loggers.rb
174
180
  - lib/insights/loggers.rb
175
- - lib/insights/loggers/base.rb
176
- - lib/insights/loggers/logging_service.rb
181
+ - lib/insights/loggers/factory.rb
182
+ - lib/insights/loggers/std_error_logger.rb
177
183
  - lib/insights/loggers/version.rb
178
184
  homepage: https://github.com/ManageIQ/manageiq-loggers
179
185
  licenses: