centralized_ruby_logger 0.0.15 → 0.0.16

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
- SHA1:
3
- metadata.gz: 84e8e418f67c78e39e6496a8c01d160abb70e6df
4
- data.tar.gz: 1d882f55078125804fa31b90a1942ce7f7ec38c7
2
+ SHA256:
3
+ metadata.gz: 3bb22fe0d8a38a7ea50b49d947081024babce01aa34f90ff8bfb7ce441dd9574
4
+ data.tar.gz: 367f73a60b64c522257eadc8202a447a8f0189956ef88808aec56dcaddf2afec
5
5
  SHA512:
6
- metadata.gz: 561dfab68d556459d62983117f97763d90fc12c775bf0db484d99b6ec4a4e26dc0614b4370889ef97bfaeff186139b7570c7f0138d9fd073f01e624bda8bd90e
7
- data.tar.gz: 663ceb2278699b4d17d8b682e2897bc2bb13bed4a45420949a711644e11dfb0560235e09a34d601ac0172711f04722aa5ef51405a2e5d461254c2189b67c967b
6
+ metadata.gz: 506e90154cc95961cf3937d82ff16ce9ce0d58a80322e2c3436307f1f2614f9cf57b8ed4e0365ab5ec1b9a4d6dea7ca44d562adb8349d3167852b442a071d8b4
7
+ data.tar.gz: c6355047fa329e7be8d38e4a88e43497f302233d8fba782a56acb59ba9fb26cec12de117f71735b1c771820bd3b47ab4a562570f4ddd2354139d371ab08f2b19
@@ -8,10 +8,15 @@ module Coralogix
8
8
  # Constructor.
9
9
  #
10
10
  # @param name - logger name.
11
- def initialize private_key, app_name, sub_system_name, debug=false, type_name="Centralized Ruby", force_compression=false, proxy={}
11
+ def initialize private_key, app_name, sub_system_name, debug=false, type_name="Centralized Ruby", force_compression=false, proxy={}, external_logger=nil
12
12
  self.debug_mode=debug
13
13
  @category = CORALOGIX_CATEGORY
14
14
  @manager = LoggerManager.new proxy
15
+ unless external_logger.nil?
16
+ DebugLogger.enabled = true
17
+ DebugLogger.external = true
18
+ DebugLogger.logger = external_logger
19
+ end
15
20
  configure(private_key, app_name, sub_system_name, type_name, force_compression)
16
21
  end
17
22
 
data/lib/debug_logger.rb CHANGED
@@ -4,33 +4,50 @@ module Coralogix
4
4
  # @private
5
5
  class DebugLogger
6
6
 
7
+ # attr_accessor :external, :enabled, :logger
8
+
7
9
  def self.initialize
8
10
  begin
9
11
  @mutex = Mutex.new
10
- @debug = false
12
+ @enabled = false
13
+ @external = false
11
14
  rescue Exception => e
12
- if @debug
15
+ if @enabled
13
16
  puts e.message
14
17
  puts e.backtrace.inspect
15
18
  end
16
19
  end
17
20
  end
18
21
 
22
+ def self.enabled=(value)
23
+ @enabled = value
24
+ end
25
+
26
+ def self.external=(value)
27
+ @external = value
28
+ end
29
+
30
+ def self.logger=(value)
31
+ @logger = value
32
+ end
33
+
19
34
  def self.debug_mode?
20
- @debug
35
+ @enabled
21
36
  end
22
37
 
23
38
  def self.debug_mode=(value)
24
39
  begin
25
- @debug = value
40
+ @enabled = value
26
41
  if value
27
42
  @logger = Logger.new("/tmp/#{LOG_FILE_NAME}", 1, 10485760)
28
43
  else
29
- @logger.close unless @logger == nil
30
- @logger = nil
44
+ if @external == false
45
+ @logger.close unless @logger == nil
46
+ @logger = nil
47
+ end
31
48
  end
32
49
  rescue Exception => e
33
- if @debug
50
+ if @enabled
34
51
  puts e.message
35
52
  puts e.backtrace.inspect
36
53
  end
@@ -39,10 +56,12 @@ module Coralogix
39
56
 
40
57
  Logger::Severity.constants.each do |level|
41
58
  define_singleton_method("#{level.downcase}") do |*args|
42
- if @debug
59
+ if @enabled
43
60
  @mutex.synchronize do
44
61
  begin
45
- puts "#{__method__.upcase}: #{Time.now.strftime('%H:%M:%S.%L')} - #{args}"
62
+ if @external == false
63
+ puts "#{__method__.upcase}: #{Time.now.strftime('%H:%M:%S.%L')} - #{args}"
64
+ end
46
65
  @logger.send("#{__method__}", args)
47
66
  rescue Exception => e
48
67
  puts e.message
data/lib/manager.rb CHANGED
@@ -84,6 +84,8 @@ module Coralogix
84
84
  @buffer << new_entry
85
85
  #Update the buffer size to reflect the new size.
86
86
  @buffer_size+=new_entry.to_json.bytesize
87
+ else
88
+ DebugLogger.warn "max logs exceeded, dropping log"
87
89
  end
88
90
  end
89
91
  rescue Exception => e
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: centralized_ruby_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Royee Goldberg
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-22 00:00:00.000000000 Z
11
+ date: 2021-03-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Coralogix Centralized Ruby Logger to send logs to Coralogix server.
14
14
  email: royee@coralogix.com
@@ -27,7 +27,7 @@ homepage: http://www.coralogix.com
27
27
  licenses:
28
28
  - MIT
29
29
  metadata: {}
30
- post_install_message:
30
+ post_install_message:
31
31
  rdoc_options: []
32
32
  require_paths:
33
33
  - lib
@@ -42,9 +42,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
44
  requirements: []
45
- rubyforge_project:
46
- rubygems_version: 2.5.2.1
47
- signing_key:
45
+ rubyforge_project:
46
+ rubygems_version: 2.7.3
47
+ signing_key:
48
48
  specification_version: 4
49
49
  summary: Coralogix Centralized Ruby Logger SDK
50
50
  test_files: []