appsignal 3.0.16-java → 3.0.17-java

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: 61a15fcd31446aaa4f813957c6480260938926b5aeaa737529e168bc79b5ea9b
4
- data.tar.gz: 3a0f796a71985048fac24343f92a79d041069470280fb78f7a51121f934397b2
3
+ metadata.gz: 84c66fc5245b46c64b7a4d031d54d5962b722cddbd70a29fc56629d398192ceb
4
+ data.tar.gz: '095d567f4576b945245623cdfc3adb5e4d0f13c57be7a346e8839c9cd4dfd917'
5
5
  SHA512:
6
- metadata.gz: 9e4764dab62e7dcb8e166d29c9b2264e47cd9285abc2b06affa8898232fa6f9ef3e734de67e3a361b01bb981acec1fdfcde4ec945162a583572a8834c68f23a6
7
- data.tar.gz: 74d11d47c32a02ffdc5da5f42aaed1c113188bb780123304492516c4aecf0b1f14fb65b8c2a3dc711dc0dd43892598b960c3a4f1b61ccbe55cc1b979ac0e8ce1
6
+ metadata.gz: 3884e316ba9c491956a37059591d6ed67cb2a068346980352d0104ab64b429498145586099470a336e4e6a82cc156fd35414c34729e239eef03a28af4227cfcc
7
+ data.tar.gz: e8be655962ae38665b68f43ef7255c9638ad36d5be796011e14cde14ef766522489ec3312a16387511b67c990f0e0076f06fd87f3b8f869e83a57a6678677e37
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # AppSignal for Ruby gem Changelog
2
2
 
3
+ ## 3.0.17
4
+
5
+ ### Fixed
6
+
7
+ - [f9d57752](https://github.com/appsignal/appsignal-ruby/commit/f9d5775217400c59a70d98e9aa96e3dcd06cb1f9) patch - Use the `log_level` option for the Ruby gem logger. Previously it only configured the extension and agent loggers. Also fixes the `debug` and `transaction_debug_mode` option if no `log_level` is configured by the app.
8
+
3
9
  ## 3.0.16
4
10
 
5
11
  ### Added
@@ -30,7 +30,6 @@ module Appsignal
30
30
  :instrument_redis => true,
31
31
  :instrument_sequel => true,
32
32
  :log => "file",
33
- :log_level => "info",
34
33
  :request_headers => %w[
35
34
  HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
36
35
  HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_CONNECTION
@@ -44,6 +43,20 @@ module Appsignal
44
43
  :transaction_debug_mode => false
45
44
  }.freeze
46
45
 
46
+ # @api private
47
+ DEFAULT_LOG_LEVEL = Logger::INFO
48
+ # Map from the `log_level` config option to Ruby's Logger level value.
49
+ #
50
+ # The trace level doesn't exist in the Ruby logger so it's mapped to debug.
51
+ # @api private
52
+ LOG_LEVEL_MAP = {
53
+ "error" => Logger::ERROR,
54
+ "warn" => Logger::WARN,
55
+ "info" => Logger::INFO,
56
+ "debug" => Logger::DEBUG,
57
+ "trace" => Logger::DEBUG
58
+ }.freeze
59
+
47
60
  ENV_TO_KEY_MAPPING = {
48
61
  "APPSIGNAL_ACTIVE" => :active,
49
62
  "APPSIGNAL_APP_NAME" => :name,
@@ -242,6 +255,18 @@ module Appsignal
242
255
  config_hash[key] = value
243
256
  end
244
257
 
258
+ def log_level
259
+ if config_hash[:debug] || config_hash[:transaction_debug_mode]
260
+ level = Logger::DEBUG
261
+ end
262
+ option = config_hash[:log_level]
263
+ if option
264
+ log_level_option = LOG_LEVEL_MAP[option]
265
+ level = log_level_option if log_level_option
266
+ end
267
+ level.nil? ? Appsignal::Config::DEFAULT_LOG_LEVEL : level
268
+ end
269
+
245
270
  def log_file_path
246
271
  path = config_hash[:log_path] || root_path && File.join(root_path, "log")
247
272
  if path && File.writable?(path)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "3.0.16".freeze
4
+ VERSION = "3.0.17".freeze
5
5
  end
data/lib/appsignal.rb CHANGED
@@ -116,12 +116,7 @@ module Appsignal
116
116
  )
117
117
 
118
118
  if config.valid?
119
- logger.level =
120
- if config[:debug]
121
- Logger::DEBUG
122
- else
123
- Logger::INFO
124
- end
119
+ logger.level = config.log_level
125
120
  if config.active?
126
121
  logger.info "Starting AppSignal #{Appsignal::VERSION} "\
127
122
  "(#{$PROGRAM_NAME}, Ruby #{RUBY_VERSION}, #{RUBY_PLATFORM})"
@@ -230,12 +225,11 @@ module Appsignal
230
225
  end
231
226
 
232
227
  logger.level =
233
- if config && config[:debug]
234
- Logger::DEBUG
228
+ if config
229
+ config.log_level
235
230
  else
236
- Logger::INFO
231
+ Appsignal::Config::DEFAULT_LOG_LEVEL
237
232
  end
238
-
239
233
  logger << @in_memory_log.string if @in_memory_log
240
234
  end
241
235
 
@@ -171,7 +171,6 @@ describe Appsignal::Config do
171
171
  :instrument_redis => true,
172
172
  :instrument_sequel => true,
173
173
  :log => "file",
174
- :log_level => "info",
175
174
  :name => "TestApp",
176
175
  :push_api_key => "abc",
177
176
  :request_headers => [],
@@ -787,4 +786,83 @@ describe Appsignal::Config do
787
786
  end
788
787
  end
789
788
  end
789
+
790
+ describe "#log_level" do
791
+ let(:options) { {} }
792
+ let(:config) { described_class.new("", nil, options) }
793
+ subject { config.log_level }
794
+
795
+ context "without any config" do
796
+ it "returns info by default" do
797
+ is_expected.to eq(Logger::INFO)
798
+ end
799
+ end
800
+
801
+ context "with debug set to true" do
802
+ let(:options) { { :debug => true } }
803
+ it { is_expected.to eq(Logger::DEBUG) }
804
+ end
805
+
806
+ context "with transaction_debug_mode set to true" do
807
+ let(:options) { { :transaction_debug_mode => true } }
808
+ it { is_expected.to eq(Logger::DEBUG) }
809
+ end
810
+
811
+ context "with log_level set to error" do
812
+ let(:options) { { :log_level => "error" } }
813
+ it { is_expected.to eq(Logger::ERROR) }
814
+ end
815
+
816
+ context "with log_level set to warn" do
817
+ let(:options) { { :log_level => "warn" } }
818
+ it { is_expected.to eq(Logger::WARN) }
819
+ end
820
+
821
+ context "with log_level set to info" do
822
+ let(:options) { { :log_level => "info" } }
823
+ it { is_expected.to eq(Logger::INFO) }
824
+ end
825
+
826
+ context "with log_level set to debug" do
827
+ let(:options) { { :log_level => "debug" } }
828
+ it { is_expected.to eq(Logger::DEBUG) }
829
+ end
830
+
831
+ context "with log_level set to trace" do
832
+ let(:options) { { :log_level => "trace" } }
833
+ it { is_expected.to eq(Logger::DEBUG) }
834
+ end
835
+
836
+ context "with debug and log_level set" do
837
+ let(:options) { { :log_level => "error", :debug => true } }
838
+
839
+ it "the log_level option is leading" do
840
+ is_expected.to eq(Logger::ERROR)
841
+ end
842
+ end
843
+
844
+ context "with transaction_debug_mode and log_level set" do
845
+ let(:options) { { :log_level => "error", :transaction_debug_mode => true } }
846
+
847
+ it "the log_level option is leading" do
848
+ is_expected.to eq(Logger::ERROR)
849
+ end
850
+ end
851
+
852
+ context "with log level set to an unknown value" do
853
+ let(:options) { { :log_level => "fatal" } }
854
+
855
+ it "prints a warning and doesn't use the log_level" do
856
+ is_expected.to eql(Logger::INFO)
857
+ end
858
+
859
+ context "with debug option set to true" do
860
+ let(:options) { { :log_level => "fatal", :debug => true } }
861
+
862
+ it "prints a warning and sets it to debug" do
863
+ is_expected.to eql(Logger::DEBUG)
864
+ end
865
+ end
866
+ end
867
+ end
790
868
  end
@@ -1236,7 +1236,7 @@ describe Appsignal do
1236
1236
  before do
1237
1237
  capture_stdout(out_stream) do
1238
1238
  initialize_config
1239
- Appsignal.config[:debug] = true
1239
+ Appsignal.config[:log_level] = "debug"
1240
1240
  Appsignal.start_logger
1241
1241
  end
1242
1242
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.16
4
+ version: 3.0.17
5
5
  platform: java
6
6
  authors:
7
7
  - Robert Beekman
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-12-08 00:00:00.000000000 Z
13
+ date: 2021-12-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack