insights-loggers-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0a703f9ed56e5648e2b33273caee743d6c88aa861d71f3cf8557b10bf3fde524
4
+ data.tar.gz: 46b9560faec957accbf07f15610295834e100feedc31b60f2ed6fcd66bfd1c06
5
+ SHA512:
6
+ metadata.gz: 3cbdee4cab8984ad70a87e89ebc1a8ed85a7232ca45a1712f56f97bcbc8672f6f1555562dde42c9fb37380493403bfab1c4e3d58728e5d0a3317cdbfca712e64
7
+ data.tar.gz: bf55346a0e11d70c7d8cbe9c7d408cd25d8338805418beddb53ab2b2f17b5bf9dd99280e40841ad3452c706ffe95126eacbf36e27215d441f4f45f19ff9ccaf6
data/.codeclimate.yml ADDED
@@ -0,0 +1,34 @@
1
+ version: '2'
2
+ prepare:
3
+ fetch:
4
+ - url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_base.yml
5
+ path: ".rubocop_base.yml"
6
+ - url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_cc_base.yml
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
12
+ checks:
13
+ argument-count:
14
+ enabled: false
15
+ complex-logic:
16
+ enabled: false
17
+ file-lines:
18
+ enabled: false
19
+ method-complexity:
20
+ config:
21
+ threshold: 11
22
+ method-count:
23
+ enabled: false
24
+ method-lines:
25
+ enabled: false
26
+ nested-control-flow:
27
+ enabled: false
28
+ return-statements:
29
+ enabled: false
30
+ plugins:
31
+ rubocop:
32
+ enabled: true
33
+ config: ".rubocop_cc.yml"
34
+ channel: rubocop-0-82
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.byebug_history
3
+ /.idea/
4
+ /.rspec_status
5
+ /.rubocop-*
6
+ /.ruby-gemset
7
+ /.ruby-version
8
+ /.yardoc
9
+ /_yardoc/
10
+ /config/database.yml
11
+ /coverage/
12
+ /doc/
13
+ /Gemfile.lock
14
+ /log/
15
+ /pkg/
16
+ /tmp/
17
+
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --format progress
2
+ --color
3
+ --order random
4
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,4 @@
1
+ inherit_from:
2
+ - ".rubocop_local.yml"
3
+ inherit_gem:
4
+ manageiq-style: ".rubocop_base.yml"
data/.rubocop_cc.yml ADDED
@@ -0,0 +1,4 @@
1
+ inherit_from:
2
+ - ".rubocop_base.yml"
3
+ - ".rubocop_cc_base.yml"
4
+ - ".rubocop_local.yml"
File without changes
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ ---
2
+ dist: xenial
3
+ language: ruby
4
+ sudo: false
5
+ cache: bundler
6
+ rvm:
7
+ - 2.5.7
8
+ - 2.6.5
9
+ before_script:
10
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
11
+ - chmod +x ./cc-test-reporter
12
+ - "./cc-test-reporter before-build"
13
+ after_script:
14
+ - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
data/.yamllint ADDED
@@ -0,0 +1,8 @@
1
+ ---
2
+ ignore: |
3
+
4
+ extends: relaxed
5
+
6
+ rules:
7
+ line-length:
8
+ max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ This project adheres to [Semantic Versioning](http://semver.org/).
5
+
6
+ ## [0.1.0] - 2021-04-26
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in insights-loggers-ruby.gemspec
6
+ gemspec
7
+
8
+ Dir.glob(File.join(__dir__, 'bundler.d/*.rb')).each { |f| eval_gemfile(File.expand_path(f, __dir__)) }
data/LICENSE.txt ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # Insights::Loggers
2
+
3
+ [![Build Status](https://travis-ci.com/RedHatInsights/insights-loggers-ruby.svg?branch=master)](https://travis-ci.org/RedHatInsights/insights-loggers-ruby)
4
+
5
+ Loggers and wrapper of [manageiq-loggers](https://github.com/ManageIQ/manageiq-loggers) for Insights ruby projects
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'insights-loggers-ruby'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install insights-loggers-ruby
22
+
23
+ ## Usage
24
+
25
+ ### Example
26
+ ```ruby
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
31
+ logger.info("test")
32
+ #{"@timestamp":"2021-04-28T12:56:28.682015 ","pid":11561,"tid":"3fd1d4c2ffd4","level":"info","message":"test","tags":["insights_application"],"labels":{"app":"insights_application"}}
33
+ #^^^standard error output (it is not return value)
34
+ #=> true
35
+ #
36
+ logger = Insights::Loggers::Base.create_logger(logger_class, {:app_name => "MyApp"})
37
+ logger.warn("test")
38
+ #{"@timestamp":"2021-04-28T13:31:40.311131 ","pid":11561,"tid":"3fd1d4c2ffd4","level":"warning","message":"test","tags":["MyApp"],"labels":{"app":"MyApp"}}
39
+ #^^^standard error output
40
+ ```
41
+ ### Logger classes
42
+ Currently supported logger classes:
43
+ ```
44
+ ManageIQ::Loggers::Base
45
+ ManageIQ::Loggers::Container
46
+ ManageIQ::Loggers::CloudWatch
47
+ ManageIQ::Loggers::Journald
48
+ Insights::Loggers::LoggingService
49
+ TopologicalInventory::Providers::Common::Logger
50
+ ```
51
+
52
+ First for refers to gem `manageiq-loggers` and
53
+ last one refers to `topological_inventory-providers-common` gem.
54
+
55
+ `insights-loggers-ruby` adds own logger `Insights::Loggers::LoggingService`
56
+ which is producing log to standard error output.
57
+ This standard error output can be consumed by [haberdasher](https://github.com/RedHatInsights/haberdasher) tool.
58
+
59
+ ### Create logger object
60
+
61
+ Logger object can be built with method:
62
+
63
+ ```
64
+ Insights::Loggers::Base.create_logger
65
+ ```
66
+ First parameter is `logger_class` and second parameter is
67
+ hash with parameters.
68
+ Supported hash parameters are:
69
+
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
72
+
73
+ ### Formatted output for `Insights::Loggers::LoggingService` logger
74
+
75
+ Logging service produces formatted output:
76
+
77
+ ```
78
+ {"@timestamp":"2021-04-28T13:31:40.311131 ",
79
+ "hostname": "test.example.com",
80
+ "pid":11561, # process id
81
+ "tid":"3fd1d4c2ffd4", # thread id
82
+ "service": "progname",
83
+ "level":"warning", #info, warning, error, debug
84
+ "message":"test",
85
+ "request_id": "REQ_ID", # Thread.current[:request_id]
86
+ "tags":["MyApp"],
87
+ "labels":{"app":"MyApp"}}
88
+ ```
89
+ - `tags` and `labels` could be set also from `ENV['LOGGER_APP_NAME']`
90
+ when app_name is not set in hash parameters.
91
+
92
+ ## Dependencies
93
+
94
+ Logging service inherits from `ManageIQ::Loggers::Container` class and
95
+ thanks to that `manageiq-loggers` is required dependency.
96
+
97
+ Usage other loggers is possible also from `manageiq-loggers` gem.
98
+
99
+ ## Development
100
+
101
+ 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.
102
+
103
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
104
+
105
+ ## Contributing
106
+
107
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ManageIQ/manageiq-loggers.
108
+
109
+ ## License
110
+
111
+ This project is available as open source under the terms of the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "insights/loggers"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,37 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "insights/loggers/version"
5
+ require "rbconfig"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "insights-loggers-ruby"
9
+ spec.version = Insights::Loggers::VERSION
10
+ spec.authors = ["Insights Authors"]
11
+
12
+ spec.summary = %q{Loggers for Insights ruby projects}
13
+ spec.homepage = "https://github.com/ManageIQ/manageiq-loggers"
14
+ spec.licenses = ["Apache-2.0"]
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_runtime_dependency "activesupport", "~> 5.0"
26
+ spec.add_runtime_dependency "topological_inventory-providers-common", "~> 2.1.5"
27
+ spec.add_runtime_dependency "manageiq-loggers", "~> 0.4", ">= 0.4.2"
28
+
29
+ spec.add_development_dependency "cloudwatchlogger", "~> 0.3.0"
30
+ spec.add_development_dependency "bundler", "~> 1.17.3"
31
+ spec.add_development_dependency "manageiq-style", "~> 1.3.0"
32
+ spec.add_development_dependency "rake", "~> 12.3", ">= 12.3.3"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
34
+ spec.add_development_dependency "simplecov", "~> 0.21.2"
35
+ spec.add_development_dependency "timecop", "~> 0.9.4"
36
+ spec.add_development_dependency "systemd-journal" if RbConfig::CONFIG['host_os'] =~ /linux/i
37
+ end
@@ -0,0 +1 @@
1
+ require "insights/loggers"
@@ -0,0 +1,2 @@
1
+ require "insights/loggers/version"
2
+ require "insights/loggers/base"
@@ -0,0 +1,55 @@
1
+ module Insights
2
+ module Loggers
3
+ class Base
4
+ def self.create_logger(logger_class, args = nil)
5
+ logger_library_loader(logger_class)
6
+ klass = logger_class.safe_constantize
7
+
8
+ if klass
9
+ logger_builder(klass, args)
10
+ else
11
+ raise ArgumentError, "Unable to load logger class #{logger_class}"
12
+ end
13
+ end
14
+
15
+ private_class_method def self.logger_builder(klass, args)
16
+ logger = if args.is_a?(Hash) && args[:log_path]
17
+ klass.new(args[:log_path]) # for ManageIQ::Loggers::Base
18
+ else
19
+ klass.new
20
+ end
21
+
22
+ logger.app_name_for_formatter(args[:app_name]) if args && args[:app_name]
23
+ logger
24
+ end
25
+
26
+ private_class_method def self.logger_library_loader(logger_class)
27
+ case logger_class
28
+ when "ManageIQ::Loggers::Base"
29
+ require "manageiq/loggers/base"
30
+ when "ManageIQ::Loggers::Container"
31
+ require "manageiq/loggers/base"
32
+ require "manageiq/loggers/container"
33
+ when "ManageIQ::Loggers::CloudWatch"
34
+ require "manageiq/loggers/base"
35
+ require "manageiq/loggers/cloud_watch"
36
+ when "ManageIQ::Loggers::Journald"
37
+ unless RbConfig::CONFIG['host_os'] =~ /linux/i
38
+ raise RuntimeError, "Logger #{logger_class} is not supported for #{RbConfig::CONFIG['host_os']}"
39
+ end
40
+
41
+ require "manageiq/loggers/base"
42
+ require "manageiq/loggers/journald"
43
+ when "Insights::Loggers::LoggingService"
44
+ require "manageiq/loggers/base"
45
+ require "manageiq/loggers/container"
46
+ require "insights/loggers/logging_service"
47
+ when "TopologicalInventory::Providers::Common::Logger"
48
+ require "topological_inventory/providers/common/logging"
49
+ else
50
+ raise ArgumentError, "Can't load libraries for #{logger_class}."
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,41 @@
1
+ module Insights
2
+ module Loggers
3
+ class LoggingService < ManageIQ::Loggers::Container
4
+ def initialize(*args)
5
+ super
6
+ self.reopen(STDERR)
7
+ self.formatter = Formatter.new
8
+ end
9
+
10
+ def app_name_for_formatter(app_name)
11
+ self.formatter.logger_app_name = app_name
12
+ end
13
+
14
+ class Formatter < ManageIQ::Loggers::Container::Formatter
15
+ attr_reader :logger_app_name
16
+ attr_writer :logger_app_name
17
+
18
+ def call(severity, time, progname, msg)
19
+ payload = {
20
+ :@timestamp => format_datetime(time),
21
+ :hostname => hostname,
22
+ :pid => $PROCESS_ID,
23
+ :tid => thread_id,
24
+ :service => progname,
25
+ :level => translate_error(severity),
26
+ :message => prefix_task_id(msg2str(msg)),
27
+ :request_id => request_id,
28
+ :tags => [app_name],
29
+ :labels => {"app" => app_name}
30
+ }.compact
31
+
32
+ JSON.generate(payload) << "\n"
33
+ end
34
+
35
+ def app_name
36
+ logger_app_name || ENV['LOGGER_APP_NAME'] || "insights_application"
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,5 @@
1
+ module Insights
2
+ module Loggers
3
+ VERSION = "0.1.0".freeze
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,215 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: insights-loggers-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Insights Authors
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-04-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: topological_inventory-providers-common
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.1.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.1.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: manageiq-loggers
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.4'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 0.4.2
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '0.4'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 0.4.2
61
+ - !ruby/object:Gem::Dependency
62
+ name: cloudwatchlogger
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 0.3.0
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 0.3.0
75
+ - !ruby/object:Gem::Dependency
76
+ name: bundler
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 1.17.3
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 1.17.3
89
+ - !ruby/object:Gem::Dependency
90
+ name: manageiq-style
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 1.3.0
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 1.3.0
103
+ - !ruby/object:Gem::Dependency
104
+ name: rake
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '12.3'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 12.3.3
113
+ type: :development
114
+ prerelease: false
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '12.3'
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 12.3.3
123
+ - !ruby/object:Gem::Dependency
124
+ name: rspec
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '3.0'
130
+ type: :development
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: '3.0'
137
+ - !ruby/object:Gem::Dependency
138
+ name: simplecov
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - "~>"
142
+ - !ruby/object:Gem::Version
143
+ version: 0.21.2
144
+ type: :development
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - "~>"
149
+ - !ruby/object:Gem::Version
150
+ version: 0.21.2
151
+ - !ruby/object:Gem::Dependency
152
+ name: timecop
153
+ requirement: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: 0.9.4
158
+ type: :development
159
+ prerelease: false
160
+ version_requirements: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - "~>"
163
+ - !ruby/object:Gem::Version
164
+ version: 0.9.4
165
+ description:
166
+ email:
167
+ executables: []
168
+ extensions: []
169
+ extra_rdoc_files: []
170
+ files:
171
+ - ".codeclimate.yml"
172
+ - ".gitignore"
173
+ - ".rspec"
174
+ - ".rubocop.yml"
175
+ - ".rubocop_cc.yml"
176
+ - ".rubocop_local.yml"
177
+ - ".travis.yml"
178
+ - ".yamllint"
179
+ - CHANGELOG.md
180
+ - Gemfile
181
+ - LICENSE.txt
182
+ - README.md
183
+ - Rakefile
184
+ - bin/console
185
+ - bin/setup
186
+ - insights-loggers-ruby.gemspec
187
+ - lib/insights-loggers.rb
188
+ - lib/insights/loggers.rb
189
+ - lib/insights/loggers/base.rb
190
+ - lib/insights/loggers/logging_service.rb
191
+ - lib/insights/loggers/version.rb
192
+ homepage: https://github.com/ManageIQ/manageiq-loggers
193
+ licenses:
194
+ - Apache-2.0
195
+ metadata: {}
196
+ post_install_message:
197
+ rdoc_options: []
198
+ require_paths:
199
+ - lib
200
+ required_ruby_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: '0'
205
+ required_rubygems_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ requirements: []
211
+ rubygems_version: 3.2.15
212
+ signing_key:
213
+ specification_version: 4
214
+ summary: Loggers for Insights ruby projects
215
+ test_files: []