diff --git a/CHANGELOG.md b/CHANGELOG.md index c86e2fb..19e8b13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Removed +- **BREAKING** Remove the Cloudwatch Logger [(#81)](https://github.com/ManageIQ/manageiq-loggers/pull/81) + ## [1.2.0] - 2024-09-30 ### Added - Test with ruby 3.1 and 3.0 [(#65)](https://github.com/ManageIQ/manageiq-loggers/pull/65) diff --git a/README.md b/README.md index 62446ac..0a97bb6 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,6 @@ Some loggers require additional gems to function correctly. These gems are not s To use the `Journald` logger, users must specify the `systemd-journal` gem as a dependency -To use the `CloudWatch` logger, users must specify the `cloudwatchlogger` gem as a dependency - ## Development 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. diff --git a/lib/manageiq/loggers.rb b/lib/manageiq/loggers.rb index fb9ab81..bdb0068 100644 --- a/lib/manageiq/loggers.rb +++ b/lib/manageiq/loggers.rb @@ -1,7 +1,6 @@ require "manageiq/loggers/base" require "manageiq/loggers/json_logger" -require "manageiq/loggers/cloud_watch" require "manageiq/loggers/container" require "manageiq/loggers/journald" diff --git a/lib/manageiq/loggers/cloud_watch.rb b/lib/manageiq/loggers/cloud_watch.rb deleted file mode 100644 index 18af40a..0000000 --- a/lib/manageiq/loggers/cloud_watch.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'active_support' -require 'active_support/core_ext/object' -require 'active_support/logger' - -module ManageIQ - module Loggers - class CloudWatch < Base - NAMESPACE_FILE = "/var/run/secrets/kubernetes.io/serviceaccount/namespace".freeze - - def self.new(*args, access_key_id: nil, secret_access_key: nil, log_group: nil, log_stream: nil) - access_key_id ||= ENV["CW_AWS_ACCESS_KEY_ID"].presence - secret_access_key ||= ENV["CW_AWS_SECRET_ACCESS_KEY"].presence - log_group ||= ENV["CLOUD_WATCH_LOG_GROUP"].presence - log_stream ||= ENV["HOSTNAME"].presence - - container_logger = ManageIQ::Loggers::Container.new - return container_logger unless access_key_id && secret_access_key && log_group && log_stream - - require 'cloudwatchlogger' - - creds = {:access_key_id => access_key_id, :secret_access_key => secret_access_key} - cloud_watch_logdev = CloudWatchLogger::Client.new(creds, log_group, log_stream) - cloud_watch_logger = super(cloud_watch_logdev) - cloud_watch_logger.wrap(container_logger) - end - - def initialize(logdev, *args) - super - self.formatter = ManageIQ::Loggers::Container::Formatter.new - end - end - end -end diff --git a/manageiq-loggers.gemspec b/manageiq-loggers.gemspec index aa908f5..5634635 100644 --- a/manageiq-loggers.gemspec +++ b/manageiq-loggers.gemspec @@ -25,7 +25,6 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency "manageiq-password", "< 2" spec.add_development_dependency "bundler" - spec.add_development_dependency "cloudwatchlogger" spec.add_development_dependency "manageiq-style", ">= 1.5.2" spec.add_development_dependency "rake", ">= 12.3.3" spec.add_development_dependency "rspec", "~> 3.0" diff --git a/spec/manageiq/cloud_watch_spec.rb b/spec/manageiq/cloud_watch_spec.rb deleted file mode 100644 index 77c774d..0000000 --- a/spec/manageiq/cloud_watch_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'cloudwatchlogger' - -describe ManageIQ::Loggers::CloudWatch do - it "unconfigured returns a Container logger" do - expect(described_class.new).to be_kind_of(ManageIQ::Loggers::Container) - end - - context "configured via env" do - around do |example| - ENV["CW_AWS_ACCESS_KEY_ID"] = "test" - ENV["CW_AWS_SECRET_ACCESS_KEY"] = "test" - ENV["CLOUD_WATCH_LOG_GROUP"] = "test" - old_hostname = ENV["HOSTNAME"] - ENV["HOSTNAME"] = "test" - - example.run - - ENV.delete("CW_AWS_ACCESS_KEY_ID") - ENV.delete("CW_AWS_SECRET_ACCESS_KEY") - ENV.delete("CLOUD_WATCH_LOG_GROUP") - old_hostname.nil? ? ENV.delete("HOSTNAME") : ENV["HOSTNAME"] = old_hostname - end - - before do - expect(CloudWatchLogger::Client::AWS_SDK::DeliveryThreadManager).to receive(:new).and_return(double("CloudWatchLogger::Client::AWS_SDK::DeliveryThreadManager", :deliver => nil)) - end - - it "the Container logger also receives the same messages" do - container_logger = ManageIQ::Loggers::Container.new - expect(ManageIQ::Loggers::Container).to receive(:new).and_return(container_logger) - - expect(container_logger).to receive(:add).with(1, nil, "Testing 1,2,3") - - described_class.new.info("Testing 1,2,3") - end - end - - context "configured via params" do - let(:params) do - { - access_key_id: 'test', - secret_access_key: 'test', - log_group: 'test', - log_stream: 'test' - } - end - - before do - expect(CloudWatchLogger::Client::AWS_SDK::DeliveryThreadManager).to receive(:new).and_return(double("CloudWatchLogger::Client::AWS_SDK::DeliveryThreadManager", :deliver => nil)) - end - - it "the Container logger also receives the same messages" do - container_logger = ManageIQ::Loggers::Container.new - expect(ManageIQ::Loggers::Container).to receive(:new).and_return(container_logger) - - expect(container_logger).to receive(:add).with(1, nil, "Testing 1,2,3") - - described_class.new(**params).info("Testing 1,2,3") - end - end -end