Skip to content

Commit c0a8ff8

Browse files
committed
Add environment variable to silence config loader messages
1 parent abd2a77 commit c0a8ff8

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

lib/hooks/core/config_loader.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ class ConfigLoader
2424
normalize_headers: true
2525
}.freeze
2626

27+
SILENCE_CONFIG_LOADER_MESSAGES = ENV.fetch(
28+
"HOOKS_SILENCE_CONFIG_LOADER_MESSAGES", "false"
29+
).downcase == "true".freeze
30+
2731
# Load and merge configuration from various sources
2832
#
2933
# @param config_path [String, Hash] Path to config file or config hash
@@ -65,7 +69,7 @@ def self.load(config_path: nil)
6569

6670
# Log overrides if any were made
6771
if overrides.any?
68-
puts "INFO: Configuration overrides applied from: #{overrides.join(', ')}"
72+
puts "INFO: Configuration overrides applied from: #{overrides.join(', ')}" unless SILENCE_CONFIG_LOADER_MESSAGES
6973
end
7074

7175
return config
@@ -112,7 +116,7 @@ def self.load_config_file(file_path)
112116
result
113117
rescue => e
114118
# Log this error with meaningful information
115-
puts "ERROR: Failed to load config file '#{file_path}': #{e.message}"
119+
puts "ERROR: Failed to load config file '#{file_path}': #{e.message}" unless SILENCE_CONFIG_LOADER_MESSAGES
116120
nil
117121
end
118122

spec/integration/global_lifecycle_hooks_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
ENV["HOOKS_SILENCE_CONFIG_LOADER_MESSAGES"] = "true" # Silence config loader messages in tests
4+
35
require_relative "../../lib/hooks"
46
require "rack/test"
57
require "json"

spec/integration/hooks_integration_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
ENV["HOOKS_SILENCE_CONFIG_LOADER_MESSAGES"] = "true" # Silence config loader messages in tests
4+
35
require_relative "../../lib/hooks"
46
require "rack/test"
57
require "json"

spec/unit/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
ENV["GITHUB_WEBHOOK_SECRET"] = FAKE_HMAC_SECRET
1414
ENV["ALT_WEBHOOK_SECRET"] = FAKE_ALT_HMAC_SECRET
15+
ENV["HOOKS_SILENCE_CONFIG_LOADER_MESSAGES"] = "true"
1516

1617
COV_DIR = File.expand_path("../../coverage", File.dirname(__FILE__))
1718

0 commit comments

Comments
 (0)