birling 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.travis.yml +5 -6
 - data/VERSION +1 -1
 - data/birling.gemspec +4 -4
 - data/lib/birling/logger.rb +49 -49
 - data/test/test_birling_logger.rb +55 -54
 - metadata +6 -6
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: a2d34d601f2ff30378ab9b5e133d806978b9da61a64de3ac878b1ed10b04fd96
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 363723fcff5a1ba4ba67ebfcd89619d4377087e780120c1ad0d37acf8cf28471
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 1b5c2cb58a1a7130b66c1dfb67aaa9b48e2a843d72f32abbc95bfdb6c087a0d688a9c080f2ed33d3728d7abe93ac250e490d44019f23f9b3af7964321061d6f0
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 73c01e0ad63f2c53350814b17342f489114255eab32f3f5ea49db0d20f6c5554e173fc21ba99b45624e0390a45200d677f3883dae6cd86821b85f6e992fc5c58
         
     | 
    
        data/.travis.yml
    CHANGED
    
    
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.3.0
         
     | 
    
        data/birling.gemspec
    CHANGED
    
    | 
         @@ -2,16 +2,16 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            # DO NOT EDIT THIS FILE DIRECTLY
         
     | 
| 
       3 
3 
     | 
    
         
             
            # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
         
     | 
| 
       4 
4 
     | 
    
         
             
            # -*- encoding: utf-8 -*-
         
     | 
| 
       5 
     | 
    
         
            -
            # stub: birling 0. 
     | 
| 
      
 5 
     | 
    
         
            +
            # stub: birling 0.3.0 ruby lib
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       8 
8 
     | 
    
         
             
              s.name = "birling".freeze
         
     | 
| 
       9 
     | 
    
         
            -
              s.version = "0. 
     | 
| 
      
 9 
     | 
    
         
            +
              s.version = "0.3.0"
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
         
     | 
| 
       12 
12 
     | 
    
         
             
              s.require_paths = ["lib".freeze]
         
     | 
| 
       13 
13 
     | 
    
         
             
              s.authors = ["Scott Tadman".freeze]
         
     | 
| 
       14 
     | 
    
         
            -
              s.date = " 
     | 
| 
      
 14 
     | 
    
         
            +
              s.date = "2021-02-17"
         
     | 
| 
       15 
15 
     | 
    
         
             
              s.description = "Mostly drop-in replacement for Logger with a more robust log rotation facility".freeze
         
     | 
| 
       16 
16 
     | 
    
         
             
              s.email = "github@tadman.ca".freeze
         
     | 
| 
       17 
17 
     | 
    
         
             
              s.extra_rdoc_files = [
         
     | 
| 
         @@ -38,7 +38,7 @@ Gem::Specification.new do |s| 
     | 
|
| 
       38 
38 
     | 
    
         
             
              ]
         
     | 
| 
       39 
39 
     | 
    
         
             
              s.homepage = "http://github.com/postageapp/birling".freeze
         
     | 
| 
       40 
40 
     | 
    
         
             
              s.licenses = ["MIT".freeze]
         
     | 
| 
       41 
     | 
    
         
            -
              s.rubygems_version = "3.1. 
     | 
| 
      
 41 
     | 
    
         
            +
              s.rubygems_version = "3.1.4".freeze
         
     | 
| 
       42 
42 
     | 
    
         
             
              s.summary = "Logger with simple log rotation system".freeze
         
     | 
| 
       43 
43 
     | 
    
         | 
| 
       44 
44 
     | 
    
         
             
              if s.respond_to? :specification_version then
         
     | 
    
        data/lib/birling/logger.rb
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class Birling::Logger
         
     | 
| 
       2 
2 
     | 
    
         
             
              # == Constants ============================================================
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
       4 
4 
     | 
    
         
             
              # These level constants are the same as the syslog system utility
         
     | 
| 
       5 
5 
     | 
    
         
             
              SEVERITY = {
         
     | 
| 
       6 
6 
     | 
    
         
             
                emergency: EMERGENCY = 0,
         
     | 
| 
         @@ -13,17 +13,17 @@ class Birling::Logger 
     | 
|
| 
       13 
13 
     | 
    
         
             
                debug: DEBUG = 7,
         
     | 
| 
       14 
14 
     | 
    
         
             
                unknown: UNKNOWN = 999
         
     | 
| 
       15 
15 
     | 
    
         
             
              }.freeze
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
       17 
17 
     | 
    
         
             
              DEFAULT_SEVERITY = UNKNOWN
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
              SEVERITY_LABEL = SEVERITY.invert.freeze
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
       21 
21 
     | 
    
         
             
              PATH_TIME_DEFAULT = {
         
     | 
| 
       22 
22 
     | 
    
         
             
                hourly: '%Y%m%d%H'.freeze,
         
     | 
| 
       23 
23 
     | 
    
         
             
                daily: '%Y%m%d'.freeze,
         
     | 
| 
       24 
24 
     | 
    
         
             
                default: '%s'.freeze
         
     | 
| 
       25 
25 
     | 
    
         
             
              }.freeze
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
       27 
27 
     | 
    
         
             
              # == Properties ===========================================================
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
              attr_reader :severity
         
     | 
| 
         @@ -38,9 +38,9 @@ class Birling::Logger 
     | 
|
| 
       38 
38 
     | 
    
         
             
              attr_reader :retain_period
         
     | 
| 
       39 
39 
     | 
    
         
             
              attr_reader :period
         
     | 
| 
       40 
40 
     | 
    
         
             
              attr_reader :rotation_time
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
       42 
42 
     | 
    
         
             
              # == Class Methods ========================================================
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
       44 
44 
     | 
    
         
             
              def self.severity(value)
         
     | 
| 
       45 
45 
     | 
    
         
             
                case (value)
         
     | 
| 
       46 
46 
     | 
    
         
             
                when Symbol
         
     | 
| 
         @@ -53,7 +53,7 @@ class Birling::Logger 
     | 
|
| 
       53 
53 
     | 
    
         
             
                  DEFAULT_SEVERITY
         
     | 
| 
       54 
54 
     | 
    
         
             
                end
         
     | 
| 
       55 
55 
     | 
    
         
             
              end
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
       57 
57 
     | 
    
         
             
              # == Instance Methods =====================================================
         
     | 
| 
       58 
58 
     | 
    
         | 
| 
       59 
59 
     | 
    
         
             
              # Use Birling.open(...) to create new instances.
         
     | 
| 
         @@ -84,50 +84,50 @@ class Birling::Logger 
     | 
|
| 
       84 
84 
     | 
    
         
             
                when String
         
     | 
| 
       85 
85 
     | 
    
         
             
                  @path = log
         
     | 
| 
       86 
86 
     | 
    
         
             
                end
         
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
       88 
88 
     | 
    
         
             
                if (@path and @period)
         
     | 
| 
       89 
89 
     | 
    
         
             
                  @rotation_time = self.next_rotation_time
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
       91 
91 
     | 
    
         
             
                  @path_time_format = (PATH_TIME_DEFAULT[@period] or PATH_TIME_DEFAULT[:default])
         
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
       93 
93 
     | 
    
         
             
                  @path_format ||=
         
     | 
| 
       94 
94 
     | 
    
         
             
                    @path.sub(/\.(\w+)$/) do |s|
         
     | 
| 
       95 
95 
     | 
    
         
             
                      '.' + @path_time_format + '.' + $1
         
     | 
| 
       96 
96 
     | 
    
         
             
                    end
         
     | 
| 
       97 
97 
     | 
    
         
             
                end
         
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
       99 
99 
     | 
    
         
             
                if (@path and !@log)
         
     | 
| 
       100 
100 
     | 
    
         
             
                  self.log_open!
         
     | 
| 
       101 
101 
     | 
    
         
             
                end
         
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
       103 
103 
     | 
    
         
             
                yield(self) if (block_given?)
         
     | 
| 
       104 
104 
     | 
    
         
             
              end
         
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
       106 
106 
     | 
    
         
             
              # Sets the severity filter for logging. Any messages with a lower severity
         
     | 
| 
       107 
107 
     | 
    
         
             
              # will be ignored. Any invalid severity options will reset the severity
         
     | 
| 
       108 
108 
     | 
    
         
             
              # filter to defaults.
         
     | 
| 
       109 
109 
     | 
    
         
             
              def severity=(value)
         
     | 
| 
       110 
110 
     | 
    
         
             
                @severity = self.class.severity(value)
         
     | 
| 
       111 
111 
     | 
    
         
             
              end
         
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
       113 
113 
     | 
    
         
             
              # Returns true if the log can be rotated, false otherwise.
         
     | 
| 
       114 
114 
     | 
    
         
             
              def can_rotate?
         
     | 
| 
       115 
115 
     | 
    
         
             
                !!@path
         
     | 
| 
       116 
116 
     | 
    
         
             
              end
         
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
       118 
118 
     | 
    
         
             
              # Sets the retention interval for log files. Value should respond to to_i
         
     | 
| 
       119 
119 
     | 
    
         
             
              # and yield an integer value that's a positive number of seconds between
         
     | 
| 
       120 
120 
     | 
    
         
             
              # rotation operations.
         
     | 
| 
       121 
121 
     | 
    
         
             
              def retain=(value)
         
     | 
| 
       122 
122 
     | 
    
         
             
                @retain = value ? value.to_i : nil
         
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
       124 
124 
     | 
    
         
             
                if (@retain_period and @retain_period <= 0)
         
     | 
| 
       125 
125 
     | 
    
         
             
                  @retain_period = nil
         
     | 
| 
       126 
126 
     | 
    
         
             
                end
         
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
       128 
128 
     | 
    
         
             
                @retain_period
         
     | 
| 
       129 
129 
     | 
    
         
             
              end
         
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
       131 
131 
     | 
    
         
             
              # An IO compatible method for writing a message to the file. Only non-empty
         
     | 
| 
       132 
132 
     | 
    
         
             
              # messages are actually logged.
         
     | 
| 
       133 
133 
     | 
    
         
             
              def write(message)
         
     | 
| 
         @@ -148,12 +148,12 @@ class Birling::Logger 
     | 
|
| 
       148 
148 
     | 
    
         
             
              # data will be written if the current log level is not sufficiently high.
         
     | 
| 
       149 
149 
     | 
    
         
             
              def log(level, message = nil, program = nil)
         
     | 
| 
       150 
150 
     | 
    
         
             
                return unless (@log)
         
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
       152 
152 
     | 
    
         
             
                level = self.class.severity(level)
         
     | 
| 
       153 
153 
     | 
    
         
             
                program ||= @program
         
     | 
| 
       154 
154 
     | 
    
         | 
| 
       155 
155 
     | 
    
         
             
                self.check_log_rotation!
         
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
       157 
157 
     | 
    
         
             
                @log.write(@formatter.call(level, @time_source.now, program, message))
         
     | 
| 
       158 
158 
     | 
    
         
             
              end
         
     | 
| 
       159 
159 
     | 
    
         
             
              alias_method :add, :log
         
     | 
| 
         @@ -167,12 +167,12 @@ class Birling::Logger 
     | 
|
| 
       167 
167 
     | 
    
         
             
              # Writes to the log file regardless of log level.
         
     | 
| 
       168 
168 
     | 
    
         
             
              def <<(message)
         
     | 
| 
       169 
169 
     | 
    
         
             
                return unless (@log)
         
     | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
       171 
171 
     | 
    
         
             
                self.check_log_rotation!
         
     | 
| 
       172 
     | 
    
         
            -
             
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
       173 
173 
     | 
    
         
             
                @log.write(message)
         
     | 
| 
       174 
174 
     | 
    
         
             
              end
         
     | 
| 
       175 
     | 
    
         
            -
             
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
       176 
176 
     | 
    
         
             
              # Each of the severity levels has an associated method name. For example:
         
     | 
| 
       177 
177 
     | 
    
         
             
              # * debug? - Returns true if the logging level is at least debug, false
         
     | 
| 
       178 
178 
     | 
    
         
             
              #            otherwise.
         
     | 
| 
         @@ -182,14 +182,14 @@ class Birling::Logger 
     | 
|
| 
       182 
182 
     | 
    
         
             
                define_method(:"#{name}?") do
         
     | 
| 
       183 
183 
     | 
    
         
             
                  @severity >= level
         
     | 
| 
       184 
184 
     | 
    
         
             
                end
         
     | 
| 
       185 
     | 
    
         
            -
             
     | 
| 
       186 
     | 
    
         
            -
                define_method(name) do |message = nil, program = nil|
         
     | 
| 
      
 185 
     | 
    
         
            +
             
     | 
| 
      
 186 
     | 
    
         
            +
                define_method(name) do |message = nil, program = nil, &block|
         
     | 
| 
       187 
187 
     | 
    
         
             
                  return unless (@log and @severity >= level)
         
     | 
| 
       188 
     | 
    
         
            -
             
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
       189 
189 
     | 
    
         
             
                  program ||= @program
         
     | 
| 
       190 
     | 
    
         
            -
             
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
       191 
191 
     | 
    
         
             
                  if (!message and block_given?)
         
     | 
| 
       192 
     | 
    
         
            -
                    message =  
     | 
| 
      
 192 
     | 
    
         
            +
                    message = block.call
         
     | 
| 
       193 
193 
     | 
    
         
             
                  end
         
     | 
| 
       194 
194 
     | 
    
         | 
| 
       195 
195 
     | 
    
         
             
                  self.check_log_rotation!
         
     | 
| 
         @@ -201,11 +201,11 @@ class Birling::Logger 
     | 
|
| 
       201 
201 
     | 
    
         
             
              # Closes the log.
         
     | 
| 
       202 
202 
     | 
    
         
             
              def close
         
     | 
| 
       203 
203 
     | 
    
         
             
                return unless (@log)
         
     | 
| 
       204 
     | 
    
         
            -
             
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
       205 
205 
     | 
    
         
             
                @log.close
         
     | 
| 
       206 
206 
     | 
    
         
             
                @log = nil
         
     | 
| 
       207 
207 
     | 
    
         
             
              end
         
     | 
| 
       208 
     | 
    
         
            -
             
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
       209 
209 
     | 
    
         
             
              # Returns true if the log is opened, false otherwise.
         
     | 
| 
       210 
210 
     | 
    
         
             
              def opened?
         
     | 
| 
       211 
211 
     | 
    
         
             
                !!@log
         
     | 
| 
         @@ -220,17 +220,17 @@ class Birling::Logger 
     | 
|
| 
       220 
220 
     | 
    
         
             
              def create_time
         
     | 
| 
       221 
221 
     | 
    
         
             
                @log and @log.ctime
         
     | 
| 
       222 
222 
     | 
    
         
             
              end
         
     | 
| 
       223 
     | 
    
         
            -
             
     | 
| 
      
 223 
     | 
    
         
            +
             
     | 
| 
       224 
224 
     | 
    
         
             
              # Returns size of the log if opened, nil otherwise.
         
     | 
| 
       225 
225 
     | 
    
         
             
              def size
         
     | 
| 
       226 
226 
     | 
    
         
             
                @log and @log.size
         
     | 
| 
       227 
227 
     | 
    
         
             
              end
         
     | 
| 
       228 
     | 
    
         
            -
             
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
       229 
229 
     | 
    
         
             
              # Returns the age of the log file in seconds if opened, nil otherwise.
         
     | 
| 
       230 
230 
     | 
    
         
             
              def age(relative_to = nil)
         
     | 
| 
       231 
231 
     | 
    
         
             
                @log and (relative_to || @time_source.now) - @log.ctime
         
     | 
| 
       232 
232 
     | 
    
         
             
              end
         
     | 
| 
       233 
     | 
    
         
            -
             
     | 
| 
      
 233 
     | 
    
         
            +
             
     | 
| 
       234 
234 
     | 
    
         
             
            protected
         
     | 
| 
       235 
235 
     | 
    
         
             
              def next_rotation_time
         
     | 
| 
       236 
236 
     | 
    
         
             
                case (@period)
         
     | 
| 
         @@ -244,21 +244,21 @@ protected 
     | 
|
| 
       244 
244 
     | 
    
         
             
                  nil
         
     | 
| 
       245 
245 
     | 
    
         
             
                end
         
     | 
| 
       246 
246 
     | 
    
         
             
              end
         
     | 
| 
       247 
     | 
    
         
            -
             
     | 
| 
      
 247 
     | 
    
         
            +
             
     | 
| 
       248 
248 
     | 
    
         
             
              def prune_logs!
         
     | 
| 
       249 
249 
     | 
    
         
             
                return unless (@path and (@retain_period or @retain_count))
         
     | 
| 
       250 
     | 
    
         
            -
             
     | 
| 
      
 250 
     | 
    
         
            +
             
     | 
| 
       251 
251 
     | 
    
         
             
                log_spec = @path.sub(/\.(\w+)$/, '*')
         
     | 
| 
       252 
     | 
    
         
            -
             
     | 
| 
      
 252 
     | 
    
         
            +
             
     | 
| 
       253 
253 
     | 
    
         
             
                logs = (Dir.glob(log_spec) - [ @path ]).collect do |p|
         
     | 
| 
       254 
254 
     | 
    
         
             
                  stat = File.stat(p)
         
     | 
| 
       255 
255 
     | 
    
         
             
                  create_time = (stat and stat.ctime or @time_source.now)
         
     | 
| 
       256 
     | 
    
         
            -
             
     | 
| 
      
 256 
     | 
    
         
            +
             
     | 
| 
       257 
257 
     | 
    
         
             
                  [ p, create_time ]
         
     | 
| 
       258 
258 
     | 
    
         
             
                end.sort_by do |r|
         
     | 
| 
       259 
259 
     | 
    
         
             
                  r[1] || @time_source.now
         
     | 
| 
       260 
260 
     | 
    
         
             
                end
         
     | 
| 
       261 
     | 
    
         
            -
             
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
       262 
262 
     | 
    
         
             
                if (@retain_period)
         
     | 
| 
       263 
263 
     | 
    
         
             
                  logs.reject! do |r|
         
     | 
| 
       264 
264 
     | 
    
         
             
                    if (Time.now - r[1] > @retain_period)
         
     | 
| 
         @@ -266,23 +266,23 @@ protected 
     | 
|
| 
       266 
266 
     | 
    
         
             
                    end
         
     | 
| 
       267 
267 
     | 
    
         
             
                  end
         
     | 
| 
       268 
268 
     | 
    
         
             
                end
         
     | 
| 
       269 
     | 
    
         
            -
             
     | 
| 
      
 269 
     | 
    
         
            +
             
     | 
| 
       270 
270 
     | 
    
         
             
                if (@retain_count)
         
     | 
| 
       271 
271 
     | 
    
         
             
                  # The logs array is sorted from oldest to newest, so retaining the N
         
     | 
| 
       272 
272 
     | 
    
         
             
                  # newest entries entails stripping them off the end with pop.
         
     | 
| 
       273 
273 
     | 
    
         | 
| 
       274 
274 
     | 
    
         
             
                  logs.pop(@retain_count)
         
     | 
| 
       275 
     | 
    
         
            -
             
     | 
| 
      
 275 
     | 
    
         
            +
             
     | 
| 
       276 
276 
     | 
    
         
             
                  FileUtils.rm_f(logs.collect { |r| r[0] })
         
     | 
| 
       277 
277 
     | 
    
         
             
                end
         
     | 
| 
       278 
278 
     | 
    
         
             
              end
         
     | 
| 
       279 
     | 
    
         
            -
             
     | 
| 
      
 279 
     | 
    
         
            +
             
     | 
| 
       280 
280 
     | 
    
         
             
              def check_log_rotation!
         
     | 
| 
       281 
281 
     | 
    
         
             
                return unless (@rotation_time)
         
     | 
| 
       282 
     | 
    
         
            -
             
     | 
| 
      
 282 
     | 
    
         
            +
             
     | 
| 
       283 
283 
     | 
    
         
             
                if (@time_source.now >= @rotation_time)
         
     | 
| 
       284 
284 
     | 
    
         
             
                  self.log_open!
         
     | 
| 
       285 
     | 
    
         
            -
             
     | 
| 
      
 285 
     | 
    
         
            +
             
     | 
| 
       286 
286 
     | 
    
         
             
                  @rotation_time = self.next_rotation_time
         
     | 
| 
       287 
287 
     | 
    
         
             
                end
         
     | 
| 
       288 
288 
     | 
    
         
             
              end
         
     | 
| 
         @@ -290,10 +290,10 @@ protected 
     | 
|
| 
       290 
290 
     | 
    
         
             
              def log_open!
         
     | 
| 
       291 
291 
     | 
    
         
             
                if (@path_format)
         
     | 
| 
       292 
292 
     | 
    
         
             
                  @current_path = @time_source.now.strftime(@path_format)
         
     | 
| 
       293 
     | 
    
         
            -
             
     | 
| 
       294 
     | 
    
         
            -
                  @log = File.open(@current_path, 'a',  
     | 
| 
      
 293 
     | 
    
         
            +
             
     | 
| 
      
 294 
     | 
    
         
            +
                  @log = File.open(@current_path, 'a', **@file_open_options)
         
     | 
| 
       295 
295 
     | 
    
         
             
                  @log.sync = true
         
     | 
| 
       296 
     | 
    
         
            -
             
     | 
| 
      
 296 
     | 
    
         
            +
             
     | 
| 
       297 
297 
     | 
    
         
             
                  if (File.symlink?(@path))
         
     | 
| 
       298 
298 
     | 
    
         
             
                    File.unlink(@path)
         
     | 
| 
       299 
299 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -301,12 +301,12 @@ protected 
     | 
|
| 
       301 
301 
     | 
    
         
             
                  unless (File.exist?(@path))
         
     | 
| 
       302 
302 
     | 
    
         
             
                    File.symlink(@current_path, @path)
         
     | 
| 
       303 
303 
     | 
    
         
             
                  end
         
     | 
| 
       304 
     | 
    
         
            -
             
     | 
| 
      
 304 
     | 
    
         
            +
             
     | 
| 
       305 
305 
     | 
    
         
             
                  self.prune_logs!
         
     | 
| 
       306 
306 
     | 
    
         
             
                else
         
     | 
| 
       307 
307 
     | 
    
         
             
                  @current_path = @path
         
     | 
| 
       308 
     | 
    
         
            -
             
     | 
| 
       309 
     | 
    
         
            -
                  @log = File.open(@current_path, 'a',  
     | 
| 
      
 308 
     | 
    
         
            +
             
     | 
| 
      
 309 
     | 
    
         
            +
                  @log = File.open(@current_path, 'a', **@file_open_options)
         
     | 
| 
       310 
310 
     | 
    
         | 
| 
       311 
311 
     | 
    
         
             
                  @log.sync = true
         
     | 
| 
       312 
312 
     | 
    
         
             
                end
         
     | 
    
        data/test/test_birling_logger.rb
    CHANGED
    
    | 
         @@ -1,30 +1,31 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.expand_path('helper',  
     | 
| 
      
 1 
     | 
    
         
            +
            require File.expand_path('helper', __dir__)
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'stringio'
         
     | 
| 
       2 
3 
     | 
    
         | 
| 
       3 
4 
     | 
    
         
             
            class TestBirlingLogger < Test::Unit::TestCase
         
     | 
| 
       4 
5 
     | 
    
         
             
              def test_defaults
         
     | 
| 
       5 
6 
     | 
    
         
             
                temp_path do |path|
         
     | 
| 
       6 
7 
     | 
    
         
             
                  log = Birling::Logger.new(path)
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
       8 
9 
     | 
    
         
             
                  assert log
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
                  assert log.opened?
         
     | 
| 
       11 
12 
     | 
    
         
             
                  assert !log.closed?
         
     | 
| 
       12 
13 
     | 
    
         
             
                  assert_equal 0, log.size
         
     | 
| 
       13 
14 
     | 
    
         
             
                  assert Time.now >= log.create_time
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
       15 
16 
     | 
    
         
             
                  assert_equal Birling::Formatter, log.formatter
         
     | 
| 
       16 
17 
     | 
    
         
             
                  assert_equal Time, log.time_source
         
     | 
| 
       17 
18 
     | 
    
         
             
                  assert_equal nil, log.period
         
     | 
| 
       18 
19 
     | 
    
         
             
                end
         
     | 
| 
       19 
20 
     | 
    
         
             
              end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
       21 
22 
     | 
    
         
             
              def test_with_handle
         
     | 
| 
       22 
23 
     | 
    
         
             
                s = StringIO.new
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
       24 
25 
     | 
    
         
             
                log = Birling::Logger.new(s)
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
       26 
27 
     | 
    
         
             
                assert log.opened?
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
       28 
29 
     | 
    
         
             
                assert_equal 0, log.size
         
     | 
| 
       29 
30 
     | 
    
         
             
              end
         
     | 
| 
       30 
31 
     | 
    
         | 
| 
         @@ -34,9 +35,9 @@ class TestBirlingLogger < Test::Unit::TestCase 
     | 
|
| 
       34 
35 
     | 
    
         
             
                buffer = StringIO.new
         
     | 
| 
       35 
36 
     | 
    
         | 
| 
       36 
37 
     | 
    
         
             
                log = Birling::Logger.new(buffer, time_source: Time::Warped)
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
       38 
39 
     | 
    
         
             
                assert log.opened?
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
       40 
41 
     | 
    
         
             
                assert_equal 0, log.size
         
     | 
| 
       41 
42 
     | 
    
         | 
| 
       42 
43 
     | 
    
         
             
                $stdout = log
         
     | 
| 
         @@ -56,21 +57,21 @@ class TestBirlingLogger < Test::Unit::TestCase 
     | 
|
| 
       56 
57 
     | 
    
         
             
              ensure
         
     | 
| 
       57 
58 
     | 
    
         
             
                $stdout = stdout
         
     | 
| 
       58 
59 
     | 
    
         
             
              end
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
       60 
61 
     | 
    
         
             
              def test_formatter
         
     | 
| 
       61 
62 
     | 
    
         
             
                formatter_called = false
         
     | 
| 
       62 
63 
     | 
    
         
             
                formatter = lambda do |severity, time, program, message|
         
     | 
| 
       63 
64 
     | 
    
         
             
                  formatter_called = true
         
     | 
| 
       64 
65 
     | 
    
         
             
                  message
         
     | 
| 
       65 
66 
     | 
    
         
             
                end
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
       67 
68 
     | 
    
         
             
                output = StringIO.new
         
     | 
| 
       68 
69 
     | 
    
         
             
                log = Birling::Logger.new(output, formatter: formatter)
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
       70 
71 
     | 
    
         
             
                log.debug("Test")
         
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
       72 
73 
     | 
    
         
             
                assert_equal true, formatter_called
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
       74 
75 
     | 
    
         
             
                output.rewind
         
     | 
| 
       75 
76 
     | 
    
         
             
                assert_equal "Test", output.read
         
     | 
| 
       76 
77 
     | 
    
         
             
              end
         
     | 
| 
         @@ -78,44 +79,44 @@ class TestBirlingLogger < Test::Unit::TestCase 
     | 
|
| 
       78 
79 
     | 
    
         
             
              def test_default_level
         
     | 
| 
       79 
80 
     | 
    
         
             
                temp_path do |path|
         
     | 
| 
       80 
81 
     | 
    
         
             
                  log = Birling::Logger.new(path)
         
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
       82 
83 
     | 
    
         
             
                  assert log
         
     | 
| 
       83 
84 
     | 
    
         | 
| 
       84 
85 
     | 
    
         
             
                  assert log.opened?
         
     | 
| 
       85 
86 
     | 
    
         
             
                  assert !log.closed?
         
     | 
| 
       86 
87 
     | 
    
         
             
                  assert_equal 0, log.size
         
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
       88 
89 
     | 
    
         
             
                  assert log.debug?
         
     | 
| 
       89 
90 
     | 
    
         | 
| 
       90 
91 
     | 
    
         
             
                  log.debug("Test")
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
       92 
93 
     | 
    
         
             
                  current_size = log.size
         
     | 
| 
       93 
94 
     | 
    
         
             
                  assert current_size > 0
         
     | 
| 
       94 
95 
     | 
    
         
             
                end
         
     | 
| 
       95 
96 
     | 
    
         
             
              end
         
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
       97 
98 
     | 
    
         
             
              def test_direct_write
         
     | 
| 
       98 
99 
     | 
    
         
             
                output = StringIO.new
         
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
       100 
101 
     | 
    
         
             
                log = Birling::Logger.new(output)
         
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
       102 
103 
     | 
    
         
             
                log << "TEST"
         
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
       104 
105 
     | 
    
         
             
                assert_equal "TEST", output.string
         
     | 
| 
       105 
106 
     | 
    
         
             
              end
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
       107 
108 
     | 
    
         
             
              def test_level_filter
         
     | 
| 
       108 
109 
     | 
    
         
             
                output = StringIO.new
         
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
       110 
111 
     | 
    
         
             
                log = Birling::Logger.new(
         
     | 
| 
       111 
112 
     | 
    
         
             
                  output,
         
     | 
| 
       112 
113 
     | 
    
         
             
                  formatter: lambda { |s, t, p, m| "#{m}\n" },
         
     | 
| 
       113 
114 
     | 
    
         
             
                  severity: :info
         
     | 
| 
       114 
115 
     | 
    
         
             
                )
         
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
       116 
117 
     | 
    
         
             
                log.debug("DEBUG")
         
     | 
| 
       117 
118 
     | 
    
         
             
                log.info("INFO")
         
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
       119 
120 
     | 
    
         
             
                output.rewind
         
     | 
| 
       120 
121 
     | 
    
         
             
                assert_equal "INFO\n", output.read
         
     | 
| 
       121 
122 
     | 
    
         
             
              end
         
     | 
| 
         @@ -127,67 +128,67 @@ class TestBirlingLogger < Test::Unit::TestCase 
     | 
|
| 
       127 
128 
     | 
    
         
             
                  assert log.debug?
         
     | 
| 
       128 
129 
     | 
    
         | 
| 
       129 
130 
     | 
    
         
             
                  log.debug("Test")
         
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
       131 
132 
     | 
    
         
             
                  current_size = log.size
         
     | 
| 
       132 
133 
     | 
    
         
             
                  assert current_size > 0
         
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
       134 
135 
     | 
    
         
             
                  create_time = log.create_time
         
     | 
| 
       135 
136 
     | 
    
         
             
                  assert create_time <= Time.now
         
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
       137 
138 
     | 
    
         
             
                  log.close
         
     | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
       139 
140 
     | 
    
         
             
                  log = Birling::Logger.new(path)
         
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
       141 
142 
     | 
    
         
             
                  assert_equal current_size, log.size
         
     | 
| 
       142 
143 
     | 
    
         
             
                  assert_equal create_time, log.create_time
         
     | 
| 
       143 
144 
     | 
    
         
             
                end
         
     | 
| 
       144 
145 
     | 
    
         
             
              end
         
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
       146 
147 
     | 
    
         
             
              def test_time_source
         
     | 
| 
       147 
148 
     | 
    
         
             
                temp_path do |path|
         
     | 
| 
       148 
149 
     | 
    
         
             
                  frozen_time = Time.now
         
     | 
| 
       149 
150 
     | 
    
         
             
                  Time::Warped.now = frozen_time
         
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
       151 
152 
     | 
    
         
             
                  logger = Birling::Logger.new(path, time_source: Time::Warped)
         
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
       153 
154 
     | 
    
         
             
                  assert_equal frozen_time, logger.time_source.now
         
     | 
| 
       154 
155 
     | 
    
         
             
                end
         
     | 
| 
       155 
156 
     | 
    
         
             
              end
         
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
       157 
158 
     | 
    
         
             
              def test_cycling
         
     | 
| 
       158 
159 
     | 
    
         
             
                temp_path(:cycle) do |path|
         
     | 
| 
       159 
160 
     | 
    
         
             
                  start = Time.now
         
     | 
| 
       160 
161 
     | 
    
         
             
                  Time::Warped.now = start
         
     | 
| 
       161 
162 
     | 
    
         
             
                  logger = Birling::Logger.new(path, period: 1, time_source: Time::Warped)
         
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
      
 163 
     | 
    
         
            +
             
     | 
| 
       163 
164 
     | 
    
         
             
                  assert_equal 1, logger.period
         
     | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
       165 
166 
     | 
    
         
             
                  current_path = logger.current_path
         
     | 
| 
       166 
167 
     | 
    
         
             
                  assert_equal '%s', logger.path_time_format
         
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
       168 
169 
     | 
    
         
             
                  logger.debug("Test")
         
     | 
| 
       169 
     | 
    
         
            -
             
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
       170 
171 
     | 
    
         
             
                  Time::Warped.now += 1
         
     | 
| 
       171 
     | 
    
         
            -
             
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
       172 
173 
     | 
    
         
             
                  logger.debug("Test")
         
     | 
| 
       173 
174 
     | 
    
         | 
| 
       174 
175 
     | 
    
         
             
                  assert_not_equal current_path, logger.current_path
         
     | 
| 
       175 
     | 
    
         
            -
             
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
       176 
177 
     | 
    
         
             
                  current_path = logger.current_path
         
     | 
| 
       177 
178 
     | 
    
         | 
| 
       178 
179 
     | 
    
         
             
                  Time::Warped.now += 1
         
     | 
| 
       179 
     | 
    
         
            -
             
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
       180 
181 
     | 
    
         
             
                  logger.debug("Test")
         
     | 
| 
       181 
     | 
    
         
            -
             
     | 
| 
      
 182 
     | 
    
         
            +
             
     | 
| 
       182 
183 
     | 
    
         
             
                  assert_not_equal current_path, logger.current_path
         
     | 
| 
       183 
184 
     | 
    
         
             
                end
         
     | 
| 
       184 
185 
     | 
    
         
             
              end
         
     | 
| 
       185 
     | 
    
         
            -
             
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
       186 
187 
     | 
    
         
             
              def test_retain_count
         
     | 
| 
       187 
188 
     | 
    
         
             
                temp_path(:cycle) do |path|
         
     | 
| 
       188 
189 
     | 
    
         
             
                  start = Time.now
         
     | 
| 
       189 
190 
     | 
    
         
             
                  Time::Warped.now = start
         
     | 
| 
       190 
     | 
    
         
            -
             
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
       191 
192 
     | 
    
         
             
                  retain_count = 10
         
     | 
| 
       192 
193 
     | 
    
         | 
| 
       193 
194 
     | 
    
         
             
                  logger = Birling::Logger.new(
         
     | 
| 
         @@ -204,23 +205,23 @@ class TestBirlingLogger < Test::Unit::TestCase 
     | 
|
| 
       204 
205 
     | 
    
         | 
| 
       205 
206 
     | 
    
         
             
                    logger.debug("Test")
         
     | 
| 
       206 
207 
     | 
    
         
             
                  end
         
     | 
| 
       207 
     | 
    
         
            -
             
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
       208 
209 
     | 
    
         
             
                  assert_equal retain_count, Dir.glob(logger.path_format % '*').length
         
     | 
| 
       209 
210 
     | 
    
         
             
                end
         
     | 
| 
       210 
211 
     | 
    
         
             
              end
         
     | 
| 
       211 
     | 
    
         
            -
             
     | 
| 
      
 212 
     | 
    
         
            +
             
     | 
| 
       212 
213 
     | 
    
         
             
              def test_default_formatter
         
     | 
| 
       213 
214 
     | 
    
         
             
                temp_path(:cycle) do |path|
         
     | 
| 
       214 
215 
     | 
    
         
             
                  logger = Birling::Logger.new(path)
         
     | 
| 
       215 
     | 
    
         
            -
             
     | 
| 
      
 216 
     | 
    
         
            +
             
     | 
| 
       216 
217 
     | 
    
         
             
                  lines = 100
         
     | 
| 
       217 
     | 
    
         
            -
             
     | 
| 
      
 218 
     | 
    
         
            +
             
     | 
| 
       218 
219 
     | 
    
         
             
                  lines.times do
         
     | 
| 
       219 
220 
     | 
    
         
             
                    logger.debug("Test")
         
     | 
| 
       220 
221 
     | 
    
         
             
                  end
         
     | 
| 
       221 
     | 
    
         
            -
             
     | 
| 
      
 222 
     | 
    
         
            +
             
     | 
| 
       222 
223 
     | 
    
         
             
                  logger.close
         
     | 
| 
       223 
     | 
    
         
            -
             
     | 
| 
      
 224 
     | 
    
         
            +
             
     | 
| 
       224 
225 
     | 
    
         
             
                  assert_equal lines, File.readlines(path).length
         
     | 
| 
       225 
226 
     | 
    
         
             
                end
         
     | 
| 
       226 
227 
     | 
    
         
             
              end
         
     | 
| 
         @@ -228,13 +229,13 @@ class TestBirlingLogger < Test::Unit::TestCase 
     | 
|
| 
       228 
229 
     | 
    
         
             
              def test_retain_period
         
     | 
| 
       229 
230 
     | 
    
         
             
                temp_path(:cycle) do |path|
         
     | 
| 
       230 
231 
     | 
    
         
             
                  retain_period = 3
         
     | 
| 
       231 
     | 
    
         
            -
             
     | 
| 
      
 232 
     | 
    
         
            +
             
     | 
| 
       232 
233 
     | 
    
         
             
                  logger = Birling::Logger.new(
         
     | 
| 
       233 
234 
     | 
    
         
             
                    path,
         
     | 
| 
       234 
235 
     | 
    
         
             
                    period: 1,
         
     | 
| 
       235 
236 
     | 
    
         
             
                    retain_period: retain_period
         
     | 
| 
       236 
237 
     | 
    
         
             
                  )
         
     | 
| 
       237 
     | 
    
         
            -
             
     | 
| 
      
 238 
     | 
    
         
            +
             
     | 
| 
       238 
239 
     | 
    
         
             
                  assert_equal true, File.exist?(path)
         
     | 
| 
       239 
240 
     | 
    
         
             
                  assert_equal true, File.symlink?(path)
         
     | 
| 
       240 
241 
     | 
    
         | 
| 
         @@ -245,7 +246,7 @@ class TestBirlingLogger < Test::Unit::TestCase 
     | 
|
| 
       245 
246 
     | 
    
         
             
                    Time::Warped.now += 1
         
     | 
| 
       246 
247 
     | 
    
         
             
                    logger.debug("Test")
         
     | 
| 
       247 
248 
     | 
    
         
             
                  end
         
     | 
| 
       248 
     | 
    
         
            -
             
     | 
| 
      
 249 
     | 
    
         
            +
             
     | 
| 
       249 
250 
     | 
    
         
             
                  assert_equal retain_period + 1, Dir.glob(logger.path_format % '*').length
         
     | 
| 
       250 
251 
     | 
    
         
             
                end
         
     | 
| 
       251 
252 
     | 
    
         
             
              end
         
     | 
| 
         @@ -257,6 +258,6 @@ class TestBirlingLogger < Test::Unit::TestCase 
     | 
|
| 
       257 
258 
     | 
    
         
             
                  invalid = (0..255).to_a.pack('C*')
         
     | 
| 
       258 
259 
     | 
    
         | 
| 
       259 
260 
     | 
    
         
             
                  logger.debug(invalid)
         
     | 
| 
       260 
     | 
    
         
            -
                end 
     | 
| 
      
 261 
     | 
    
         
            +
                end
         
     | 
| 
       261 
262 
     | 
    
         
             
              end
         
     | 
| 
       262 
263 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: birling
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.3.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Scott Tadman
         
     | 
| 
       8 
     | 
    
         
            -
            autorequire: 
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-02-17 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -81,7 +81,7 @@ homepage: http://github.com/postageapp/birling 
     | 
|
| 
       81 
81 
     | 
    
         
             
            licenses:
         
     | 
| 
       82 
82 
     | 
    
         
             
            - MIT
         
     | 
| 
       83 
83 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       84 
     | 
    
         
            -
            post_install_message: 
     | 
| 
      
 84 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
       85 
85 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       86 
86 
     | 
    
         
             
            require_paths:
         
     | 
| 
       87 
87 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -96,8 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       96 
96 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       97 
97 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       98 
98 
     | 
    
         
             
            requirements: []
         
     | 
| 
       99 
     | 
    
         
            -
            rubygems_version: 3.1. 
     | 
| 
       100 
     | 
    
         
            -
            signing_key: 
     | 
| 
      
 99 
     | 
    
         
            +
            rubygems_version: 3.1.4
         
     | 
| 
      
 100 
     | 
    
         
            +
            signing_key:
         
     | 
| 
       101 
101 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       102 
102 
     | 
    
         
             
            summary: Logger with simple log rotation system
         
     | 
| 
       103 
103 
     | 
    
         
             
            test_files: []
         
     |