stackify-ruby-apm 1.0.0 → 1.0.1

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
  SHA1:
3
- metadata.gz: 6bd379b0656760e155c8796bf1774627e593ecbe
4
- data.tar.gz: cb1f771b879d3c21dafc339e7f1cb874f592f9fb
3
+ metadata.gz: 1b769d0f8ea6c9ec534a343fb2db63c355857cd0
4
+ data.tar.gz: a670f3472367c5d18abb2d73ab5a7bf6c53c3414
5
5
  SHA512:
6
- metadata.gz: be773012e733b98d520a0605f9a6fe85f79a06feddfda47046479929eba89b161a50528e0bc8188717ad2d5004fc236b71f720941f78378baeb74ae87f0f564f
7
- data.tar.gz: bae740a96d52bd9905af652998a3f5440f836028e1d000684e496ea37f5fd8b0c50e9f752b02ada9b84e341a6fcd2f44c9409d7efc96e6f26b627d9d9630b0a5
6
+ metadata.gz: 255d6443ed6fc90b60bebce9282807d988b746fb2b3a08b5b1748f4db5aa6a84834561c29bc8182d0bfb32a963836cb546a6087fcbeeef96a6a39f86e7d50720
7
+ data.tar.gz: fb3beadebaf884ddcacf61a34701e5cfc86177f067ec9e9956ef2d6de5db3e8ef49fdea9df24922c1d5470c081c3f18e7162bd82d4ae8abb6dd6ebd2e5510df8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stackify-ruby-apm (1.0.0)
4
+ stackify-ruby-apm (1.0.1)
5
5
  concurrent-ruby (~> 1.0)
6
6
  delegate_matcher (~> 0.4)
7
7
 
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Starts the Monkey patch for the generated log by not including the header
4
+ #
5
+ #
6
+ # @param file
7
+ # @removed the header of the generated log
8
+ module StackifyRubyAPM
9
+ # @api private
10
+ class LogDevice < Logger::LogDevice
11
+ def add_log_header(file)
12
+ # Make it only empty.
13
+ end
14
+
15
+ # This is the monkeypatch of core Logger method where reformats when shifting log age the filename when creating the file log.
16
+
17
+ # rubocop:disable Style/RescueModifier
18
+ # rubocop:disable Lint/RescueWithoutErrorClass
19
+ # Newly created file example <file>-2.log is the latest appended log
20
+ def shift_log_age
21
+ # set a temporary filename that doesn't have the increment prefix and .log format.
22
+ temp_filename = @filename.gsub(/\-(d*\.?\d*).log/, '')
23
+ # set a temporary file increment while stripping the current filename and retain the number
24
+ txttemp_fileincrement = @filename.gsub(temp_filename,'')
25
+ txttemp_fileincrement = txttemp_fileincrement.gsub('-','')
26
+ txttemp_fileincrement = txttemp_fileincrement.gsub('.log','')
27
+
28
+ # convert the string value to integer
29
+ current_fileprefix = txttemp_fileincrement.to_i
30
+ # assign as filename counter
31
+ filename_counter = current_fileprefix
32
+ if FileTest.exist?(@filename)
33
+ filename_counter = current_fileprefix + 1
34
+ else
35
+ ctr_flagger = 0
36
+ # a loop that check if the number of filenames if exists or not
37
+ (1).upto(current_fileprefix) do |i|
38
+ temp_oldfile = "#{temp_filename}-#{i}.log"
39
+ ctr_flagger = ctr_flagger + 1 if FileTest.exist?(temp_oldfile)
40
+ end
41
+ # if the counter is 0 then set the filename counter to 1
42
+ filename_counter = 1 if ctr_flagger < 0
43
+ end
44
+
45
+ @dev.close rescue nil
46
+
47
+ temp_newfilename = "#{temp_filename}-#{filename_counter}.log"
48
+ @filename = temp_newfilename
49
+ @dev = create_logfile(@filename)
50
+
51
+ true
52
+ end
53
+
54
+ # This is the monkeypatch of core Logger method where reformats the file name when creating the file log.
55
+ def shift_log_period(period_end)
56
+ puts "shift_log_period(period_end) mao ni"
57
+
58
+ suffix = period_end.strftime(@shift_period_suffix)
59
+ age_file = "#{@filename}.#{suffix}"
60
+ if FileTest.exist?(age_file)
61
+ # try to avoid filename crash caused by Timestamp change.
62
+ idx = 1
63
+ # .99 can be overridden; avoid too much file search with 'loop do'
64
+ while idx < 100
65
+ idx += 1
66
+ age_file = "#{@filename}-#{idx}.#{suffix}"
67
+ break unless FileTest.exist?(age_file)
68
+ end
69
+ end
70
+ @dev.close rescue nil
71
+ File.rename(@filename.to_s, age_file)
72
+ @dev = create_logfile(@filename)
73
+
74
+ true
75
+ end
76
+ # rubocop:enable Style/RescueModifier
77
+ # rubocop:enable Lint/RescueWithoutErrorClass
78
+ end
79
+ end
@@ -1,65 +1,39 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Starts the Monkey patch for the generated log by not including the header
2
4
  #
5
+ #
3
6
  # @param file
4
7
  # @removed the header of the generated log
5
8
  module StackifyRubyAPM
6
-
9
+ # @api private
7
10
  class StackifyLogger < Logger
8
-
11
+ # rubocop:disable Style/NumericLiterals
12
+ # rubocop:disable Style/GuardClause
13
+ # rubocop:disable Metrics/ParameterLists
14
+ # rubocop:disable Lint/UnusedMethodArgument
9
15
  def initialize(logdev, shift_age = 0, shift_size = 1048576, level: DEBUG,
10
- progname: nil, formatter: nil, datetime_format: nil,
11
- shift_period_suffix: '%Y%m%d')
16
+ progname: nil, formatter: nil, datetime_format: nil,
17
+ shift_period_suffix: '%Y%m%d')
12
18
  super(nil) # this prevents it from initializing a LogDevice
13
19
  @logdev = nil
14
20
  if logdev
15
21
  new_logdev = logdev
16
- if (logdev.instance_of? String)
17
- temp_filename = logdev.gsub(".log", "")
18
- new_logdev = temp_filename + "-1.log"
22
+ if logdev.instance_of? String
23
+ temp_filename = logdev.gsub('.log', '')
24
+ new_logdev = temp_filename + '-1.log'
19
25
  end
20
-
21
- @logdev = LogDevice.new(new_logdev, :shift_age => shift_age,
22
- :shift_size => shift_size,
23
- :shift_period_suffix => shift_period_suffix)
26
+ @logdev = LogDevice.new(new_logdev, shift_age: shift_age,
27
+ shift_size: shift_size,
28
+ shift_period_suffix: shift_period_suffix)
24
29
  end
25
30
  end
26
- class LogDevice < Logger::LogDevice
27
- def add_log_header(file)
28
- end
29
- # This is the monkeypatch of core Logger method where reformats when shifting log age the filename when creating the file log.
30
- def shift_log_age
31
- temp_filename = @filename.gsub(/\-([0-9]).log/,"")
32
- (@shift_age-1).downto(2) do |i|
33
- if FileTest.exist?("#{temp_filename}-#{i}.log")
34
- File.rename("#{temp_filename}-#{i}.log", "#{temp_filename}-#{i+1}.log")
35
- end
36
- end
37
- @dev.close rescue nil
38
- File.rename("#{temp_filename}-1.log", "#{temp_filename}-2.log")
39
- @dev = create_logfile(@filename)
31
+ require 'stackify/logger/log_device'
32
+ # rubocop:enable Style/NumericLiterals
33
+ # rubocop:enable Style/GuardClause
34
+ # rubocop:enable Metrics/ParameterLists
35
+ # rubocop:enable Lint/UnusedMethodArgument
40
36
 
41
- return true
42
- end
43
- # This is the monkeypatch of core Logger method where reformats the file name when creating the file log.
44
- def shift_log_period(period_end)
45
- suffix = period_end.strftime(@shift_period_suffix)
46
- age_file = "#{@filename}.#{suffix}"
47
- if FileTest.exist?(age_file)
48
- # try to avoid filename crash caused by Timestamp change.
49
- idx = 1
50
- # .99 can be overridden; avoid too much file search with 'loop do'
51
- while idx < 100
52
- idx += 1
53
- age_file = "#{@filename}-#{idx}.#{suffix}"
54
- break unless FileTest.exist?(age_file)
55
- end
56
- end
57
- @dev.close rescue nil
58
- File.rename("#{@filename}", age_file)
59
- @dev = create_logfile(@filename)
60
37
 
61
- return true
62
- end
63
- end
64
38
  end
65
- end
39
+ end
@@ -1,63 +1,28 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Starts the Monkey patch for the generated log by not including the header
2
4
  #
5
+ #
3
6
  # @param file
4
7
  # @removed the header of the generated log
5
8
  module StackifyRubyAPM
9
+ # @api private
6
10
  class StackifyLogger < Logger
7
-
11
+ # rubocop:disable Style/NumericLiterals
12
+ # rubocop:disable Style/GuardClause
8
13
  def initialize(logdev, shift_age = 0, shift_size = 1048576)
9
14
  super(nil) # this prevents it from initializing a LogDevice
10
15
  @logdev = nil
11
16
  if logdev
12
17
  new_logdev = logdev
13
- if (logdev.instance_of? String)
14
- temp_filename = logdev.gsub(".log", "")
15
- new_logdev = temp_filename + "-1.log"
18
+ if logdev.instance_of? String
19
+ temp_filename = logdev.gsub('.log', '')
20
+ new_logdev = temp_filename + '-1.log'
16
21
  end
17
-
18
- @logdev = LogDevice.new(new_logdev, :shift_age => shift_age,
19
- :shift_size => shift_size)
20
- end
21
- end
22
-
23
- class LogDevice < Logger::LogDevice
24
-
25
- def add_log_header(file)
26
- end
27
- # This is the monkeypatch of core Logger method where reformats when shifting log age the filename when creating the file log.
28
- def shift_log_age
29
- temp_filename = @filename.gsub(/\-([0-9]).log/,"")
30
- (@shift_age-1).downto(2) do |i|
31
- if FileTest.exist?("#{temp_filename}-#{i}.log")
32
- File.rename("#{temp_filename}-#{i}.log", "#{temp_filename}-#{i+1}.log")
33
- end
34
- end
35
- @dev.close rescue nil
36
- File.rename("#{temp_filename}-1.log", "#{temp_filename}-2.log")
37
- @dev = create_logfile(@filename)
38
-
39
- return true
40
- end
41
- # This is the monkeypatch of core Logger method where reformats the file name when creating the file log.
42
- def shift_log_period(period_end)
43
- suffix = period_end.strftime(@shift_period_suffix)
44
- age_file = "#{@filename}.#{suffix}"
45
- if FileTest.exist?(age_file)
46
- # try to avoid filename crash caused by Timestamp change.
47
- idx = 1
48
- # .99 can be overridden; avoid too much file search with 'loop do'
49
- while idx < 100
50
- idx += 1
51
- age_file = "#{@filename}-#{idx}.#{suffix}"
52
- break unless FileTest.exist?(age_file)
53
- end
54
- end
55
- @dev.close rescue nil
56
- File.rename("#{@filename}", age_file)
57
- @dev = create_logfile(@filename)
58
-
59
- return true
22
+ @logdev = LogDevice.new(new_logdev, shift_age: shift_age,
23
+ shift_size: shift_size)
60
24
  end
61
25
  end
26
+ require 'stackify/logger/log_device'
62
27
  end
63
- end
28
+ end
@@ -1,4 +1,4 @@
1
1
  # Sets the version of the APM
2
2
  module StackifyRubyAPM
3
- VERSION = '1.0.0'.freeze
3
+ VERSION = '1.0.1'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackify-ruby-apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stackify
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-10 00:00:00.000000000 Z
11
+ date: 2019-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -111,6 +111,7 @@ files:
111
111
  - lib/stackify/instrumenter.rb
112
112
  - lib/stackify/internal_error.rb
113
113
  - lib/stackify/log.rb
114
+ - lib/stackify/logger/log_device.rb
114
115
  - lib/stackify/logger/logger_high_version.rb
115
116
  - lib/stackify/logger/logger_lower_version.rb
116
117
  - lib/stackify/middleware.rb