lumberjack 1.2.7 → 1.2.9

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: 0ba28430c423311445a80559e0bd6fdfbfdfed90edcd4dda89d9e5d635d75ec9
4
- data.tar.gz: 5507d016ad2b7dcf13e38616496e2b9e5c18e456eb1ad6bdfeceb66386eae403
3
+ metadata.gz: 9d05405664f1f85b1a68eb24c21a89d3b57ea8caf09513a348a138d53f1870b0
4
+ data.tar.gz: 1ccc42fdd657ab4acf89bab8bfd7fb5e7d69d3825367483c49ee10c5c6e037d1
5
5
  SHA512:
6
- metadata.gz: 7bf2c9640012487f994d8e4eaabf85e9b4a3fbae828d0a0bccab71cfa7af8820da199b72d04764db4b6d9e7439ac620f49578b0a20b8c77c01f4ea496616ff4c
7
- data.tar.gz: fb7d9b44ca1bbbd1a2727252c5b9f8885f8a374cd24e0fa34f38b9fca2cfa0444d603d15ccdec743c247251c0622d9153ecbe1b0d9c609da24b38511957ba190
6
+ metadata.gz: b48a0035d1adf22768071e6025692f001a8d13b931314ab0b6ea9131696bcb38d321db5fc1246bf2c49623cad26770bfdb32fe0e8e169ae455322e2693dad8e8
7
+ data.tar.gz: f80ae18348c1a3e5261aa27051d4cf3e087550e0d57d3a13459da6f7641e0ea270382478108127f03f6b7596faab27d8d3f92488fbbb2cb0c50c4d247ac61910
data/CHANGELOG.md CHANGED
@@ -1,124 +1,182 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## 1.2.9
8
+
9
+ ### Added
10
+ - Allow passing in formatters as class names when adding them.
11
+ - Allow passing in formatters initialization arguments when adding them.
12
+ - Add truncate formatter for capping the length of log messages.
13
+
14
+ ## 1.2.8
15
+
16
+ ### Added
17
+ - Add `Logger#untagged` to remove previously set logging tags from a block.
18
+ - Return result of the block when a block is passed to `Logger#tag`.
19
+
1
20
  ## 1.2.7
2
21
 
3
- * Allow passing frozen hashes to `Logger.tag`. Tags passed to this method are now duplicated so the logger maintains it's own copy of the hash.
22
+ ### Fixed
23
+ - Allow passing frozen hashes to `Logger#tag`. Tags passed to this method are now duplicated so the logger maintains it's own copy of the hash.
4
24
 
5
25
  ## 1.2.6
6
26
 
7
- * Fix Logger#tag so it only ads to the current block's logger tags instead of the global tags if called inside a `Logger#tag` block.
8
- * Add Logger#remove_tag
27
+ ### Added
28
+ - Add Logger#remove_tag
29
+
30
+ ### Fixed
31
+ - Fix `Logger#tag` so it only ads to the current block's logger tags instead of the global tags if called inside a `Logger#tag` block.
32
+
9
33
 
10
34
  ## 1.2.5
11
35
 
12
- * Fix logic with recursive reference guard in StructuredFormatter so it only suppresses Enumerable references.
13
- * Add support for bang methods (error!) for setting the log level.
36
+ ### Added
37
+ - Add support for bang methods (error!) for setting the log level.
38
+
39
+ ### Fixed
40
+ - Fixed logic with recursive reference guard in StructuredFormatter so it only suppresses Enumerable references.
14
41
 
15
42
  ## 1.2.4
16
43
 
17
- * Enhance ActiveSupport::TaggedLogging support so code that Lumberjack loggers can be wrapped with a tagged logger.
44
+ ### Added
45
+ - Enhance `ActiveSupport::TaggedLogging` support so code that Lumberjack loggers can be wrapped with a tagged logger.
18
46
 
19
47
  ## 1.2.3
20
48
 
21
- * Fix structured formatter so no-recursive, duplicate references are allowed.
49
+ ### Fixed
50
+ - Fix structured formatter so no-recursive, duplicate references are allowed.
22
51
 
23
52
  ## 1.2.2
24
53
 
25
- * Prevent infinite loops in the structured formatter where objects have backreferences to each other.
54
+ ### Fixed
55
+ - Prevent infinite loops in the structured formatter where objects have backreferences to each other.
26
56
 
27
57
  ## 1.2.1
28
58
 
29
- * Prevent infinite loops where logging a statement triggers the logger.
59
+ ### Fixed
60
+ - Prevent infinite loops where logging a statement triggers the logger.
30
61
 
31
62
  ## 1.2.0
32
63
 
33
- * Enable compatibility with ActiveSupport::TaggedLogger by calling `tagged_logger!` on a logger.
34
- * Add `tag_formatter` to logger to specify formatting of tags for output.
35
- * Allow adding and removing classes by name to formatters.
36
- * Allow adding and removing multiple classes in a single call to a formatter.
37
- * Allow using symbols and strings as log level for silencing a logger.
38
- * Ensure flusher thread gets stopped when logger is closed.
39
- * Add writer for logger device attribute.
40
- * Handle passing an array of devices to a multi device.
41
- * Helper method to get a tag with a specified name.
42
- * Add strip formatter to strip whitespace from strings.
43
- * Support non-alpha numeric characters in template variables.
44
- * Add backtrace cleaner to ExceptionFormatter.
64
+ ### Added
65
+ - Enable compatibility with `ActiveSupport::TaggedLogger` by calling `tagged_logger!` on a logger.
66
+ - Add `tag_formatter` to logger to specify formatting of tags for output.
67
+ - Allow adding and removing classes by name to formatters.
68
+ - Allow adding and removing multiple classes in a single call to a formatter.
69
+ - Allow using symbols and strings as log level for silencing a logger.
70
+ - Ensure flusher thread gets stopped when logger is closed.
71
+ - Add writer for logger device attribute.
72
+ - Handle passing an array of devices to a multi device.
73
+ - Helper method to get a tag with a specified name.
74
+ - Add strip formatter to strip whitespace from strings.
75
+ - Support non-alpha numeric characters in template variables.
76
+ - Add backtrace cleaner to ExceptionFormatter.
45
77
 
46
78
  ## 1.1.1
47
79
 
48
- * Replace Procs in tag values with the value of calling the Proc in log entries.
80
+ ### Added
81
+ - Replace Procs in tag values with the value of calling the Proc in log entries.
49
82
 
50
83
  ## 1.1.0
51
84
 
52
- * Change Lumberjack::Logger to inherit from ::Logger
53
- * Add support for tags on log messages
54
- * Add global tag context for all loggers
55
- * Add per logger tags and tag contexts
56
- * Reimplement unit of work id as a tag on log entries
57
- * Add support for setting datetime format on log devices
58
- * Performance optimizations
59
- * Add Multi device to output to multiple devices
60
- * Add DateTimeFormatter, IdFormatter, ObjectFormatter, and StructuredFormatter
61
- * Add rack Context middleware for setting thread global context
62
- * End support for ruby versions < 2.3
63
- * Add support for modules in formatters
85
+ ### Added
86
+ - Change `Lumberjack::Logger` to inherit from ::Logger
87
+ - Add support for tags on log messages
88
+ - Add global tag context for all loggers
89
+ - Add per logger tags and tag contexts
90
+ - Reimplement unit of work id as a tag on log entries
91
+ - Add support for setting datetime format on log devices
92
+ - Performance optimizations
93
+ - Add Multi device to output to multiple devices
94
+ - Add `DateTimeFormatter`, `IdFormatter`, `ObjectFormatter`, and `StructuredFormatter`
95
+ - Add rack `Context` middleware for setting thread global context
96
+ - Add support for modules in formatters
97
+
98
+ ### Removed
99
+ - End support for ruby versions < 2.3
64
100
 
65
101
  ## 1.0.13
66
102
 
67
- * Reduce amount of code executed inside a mutex lock when writing to the logger stream.
68
- * Added `:min_roll_check` option to `Lumberjack::Device::RollingLogFile` to reduce file system checks. Default is now to only check if a file needs to be rolled at most once per second.
69
- * Force immutable strings for Ruby versions that support them.
103
+ ### Added
104
+ - Added `:min_roll_check` option to `Lumberjack::Device::RollingLogFile` to reduce file system checks. Default is now to only check if a file needs to be rolled at most once per second.
105
+ - Force immutable strings for Ruby versions that support them.
106
+
107
+ ### Changed
108
+ - Reduce amount of code executed inside a mutex lock when writing to the logger stream.
70
109
 
71
110
  ## 1.0.12
72
111
 
73
- * Add support for ActionDispatch request id for better Rails compatibility.
112
+ ### Added
113
+ - Add support for `ActionDispatch` request id for better Rails compatibility.
74
114
 
75
115
  ## 1.0.11
76
116
 
77
- * Fix Ruby 2.4 deprecation warning on Fixnum (thanks koic).
78
- * Fix gemspec files to be flat array (thanks e2).
117
+ ### Fixed
118
+ - Fix Ruby 2.4 deprecation warning on Fixnum (thanks koic).
119
+ - Fix gemspec files to be flat array (thanks e2).
79
120
 
80
121
  ## 1.0.10
81
122
 
82
- * Expose option to manually roll log files.
83
- * Minor code cleanup.
123
+ ### Added
124
+ - Expose option to manually roll log files.
125
+
126
+ ### Changed
127
+ - Minor code cleanup.
84
128
 
85
129
  ## 1.0.9
86
130
 
87
- * Add method so Formatter is compatible with ActiveSupport logging extensions.
131
+ ### Added
132
+ - Add method so Formatter is compatible with `ActiveSupport` logging extensions.
88
133
 
89
134
  ## 1.0.8
90
135
 
91
- * Fix another internal variable name conflict with ActiveSupport logging extensions.
136
+ ### Fixed
137
+ - Fix another internal variable name conflict with `ActiveSupport` logging extensions.
92
138
 
93
139
  ## 1.0.7
94
140
 
95
- * Fix broken formatter attribute method.
141
+ ### Fixed
142
+ - Fix broken formatter attribute method.
96
143
 
97
144
  ## 1.0.6
98
145
 
99
- * Fix internal variable name conflict with ActiveSupport logging extensions.
146
+ ### Fixed
147
+ - Fix internal variable name conflict with `ActiveSupport` logging extensions.
100
148
 
101
149
  ## 1.0.5
102
150
 
103
- * Update docs.
104
- * Remove autoload calls to make thread safe.
105
- * Make compatible with Ruby 2.1.1 Pathname.
106
- * Make compatible with standard library Logger's use of progname as default message.
151
+ ### Changed
152
+ - Update docs.
153
+ - Remove autoload calls to make thread safe.
154
+ - Make compatible with Ruby 2.1.1 Pathname.
155
+ - Make compatible with standard library Logger's use of progname as default message.
107
156
 
108
157
  ## 1.0.4
109
158
 
110
- * Add ability to supply a unit of work id for a block instead of having one generated every time.
159
+ ### Added
160
+ - Add ability to supply a unit of work id for a block instead of having one generated every time.
111
161
 
112
162
  ## 1.0.3
113
163
 
114
- * Change log file output format to binary to avoid encoding warnings.
115
- * Fixed bug in log file rolling that left the file locked.
164
+ ### Fixed
165
+ - Change log file output format to binary to avoid encoding warnings.
166
+ - Fixed bug in log file rolling that left the file locked.
116
167
 
117
168
  ## 1.0.2
118
169
 
119
- * Remove deprecation warnings under ruby 1.9.3.
120
- * Add more error checking around file rolling.
170
+ ### Fixed
171
+ - Remove deprecation warnings under ruby 1.9.3.
172
+ - Add more error checking around file rolling.
121
173
 
122
174
  ## 1.0.1
123
175
 
124
- * Writes are no longer buffered by default.
176
+ ### Fixed
177
+ - Writes are no longer buffered by default.
178
+
179
+ ## 1.0.0
180
+
181
+ ### Added
182
+ - Initial release
data/README.md CHANGED
@@ -1,13 +1,14 @@
1
- # Lumberjack
2
-
3
- [![Build Status](https://travis-ci.org/bdurand/lumberjack.svg?branch=master)](https://travis-ci.org/bdurand/lumberjack)
1
+ ![Continuous Integration](https://github.com/bdurand/lumberjack/workflows/Continuous%20Integration/badge.svg)
4
2
  [![Maintainability](https://api.codeclimate.com/v1/badges/a0abc03721fff9b0cde1/maintainability)](https://codeclimate.com/github/bdurand/lumberjack/maintainability)
3
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
4
+
5
+ # Lumberjack
5
6
 
6
7
  Lumberjack is a simple, powerful, and fast logging implementation in Ruby. It uses nearly the same API as the Logger class in the Ruby standard library and as ActiveSupport::BufferedLogger in Rails.
7
8
 
8
9
  ## Usage
9
10
 
10
- This code aims to be extremely simple to use. The core interface it the Lumberjack::Logger which is used to log messages (which can be any object) with a specified Severity. Each logger has a level associated with it and messages are only written if their severity is greater than or equal to the level.
11
+ This code aims to be extremely simple to use. The core interface is the Lumberjack::Logger which is used to log messages (which can be any object) with a specified Severity. Each logger has a level associated with it and messages are only written if their severity is greater than or equal to the level.
11
12
 
12
13
  ```ruby
13
14
  logger = Lumberjack::Logger.new("logs/application.log") # Open a new log file with INFO level
@@ -40,7 +41,7 @@ The following information is recorded for each message:
40
41
 
41
42
  ### Tags
42
43
 
43
- You can use tags to provide additional meta data about a log message or the context that the log message is being made in. Using tags can keep you log messages clean. You can avoid string interoplation to add additional meta data.
44
+ You can use tags to provide additional meta data about a log message or the context that the log message is being made in. Using tags can keep your log messages clean. You can avoid string interpolation to add additional meta data.
44
45
 
45
46
  Each of the logger methods includes an additional argument that can be used to specify tags on a messsage:
46
47
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.7
1
+ 1.2.9
@@ -5,12 +5,16 @@ module Lumberjack
5
5
  class Context
6
6
  attr_reader :tags
7
7
 
8
+ # @param [Context] parent_context A parent context to inherit tags from.
8
9
  def initialize(parent_context = nil)
9
10
  @tags = {}
10
11
  @tags.merge!(parent_context.tags) if parent_context
11
12
  end
12
13
 
13
14
  # Set tags on the context.
15
+ #
16
+ # @param [Hash] tags The tags to set.
17
+ # @return [void]
14
18
  def tag(tags)
15
19
  tags.each do |key, value|
16
20
  @tags[key.to_s] = value
@@ -18,16 +22,25 @@ module Lumberjack
18
22
  end
19
23
 
20
24
  # Get a context tag.
25
+ #
26
+ # @param [String, Symbol] key The tag key.
27
+ # @return [Object] The tag value.
21
28
  def [](key)
22
29
  @tags[key.to_s]
23
30
  end
24
31
 
25
32
  # Set a context tag.
33
+ #
34
+ # @param [String, Symbol] key The tag key.
35
+ # @param [Object] value The tag value.
36
+ # @return [void]
26
37
  def []=(key, value)
27
38
  @tags[key.to_s] = value
28
39
  end
29
40
 
30
41
  # Clear all the context data.
42
+ #
43
+ # @return [void]
31
44
  def reset
32
45
  @tags.clear
33
46
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literals: true
2
2
 
3
- require 'date'
3
+ require "date"
4
4
 
5
5
  module Lumberjack
6
6
  class Device
@@ -13,10 +13,13 @@ module Lumberjack
13
13
  # Create a new logging device to the specified file. The period to roll the file is specified
14
14
  # with the :roll option which may contain a value of :daily, :weekly,
15
15
  # or :monthly.
16
+ #
17
+ # @param [String, Pathname] path The path to the log file.
18
+ # @param [Hash] options The options for the device.
16
19
  def initialize(path, options = {})
17
20
  @manual = options[:manual]
18
21
  @file_date = Date.today
19
- if options[:roll] && options[:roll].to_s.match(/(daily)|(weekly)|(monthly)/i)
22
+ if options[:roll]&.to_s&.match(/(daily)|(weekly)|(monthly)/i)
20
23
  @roll_period = $~[0].downcase.to_sym
21
24
  options.delete(:roll)
22
25
  else
@@ -25,17 +28,23 @@ module Lumberjack
25
28
  super
26
29
  end
27
30
 
31
+ # The date based suffix for file.
32
+ #
33
+ # @return [String]
28
34
  def archive_file_suffix
29
35
  case @roll_period
30
36
  when :weekly
31
- "#{@file_date.strftime('week-of-%Y-%m-%d')}"
37
+ @file_date.strftime("week-of-%Y-%m-%d").to_s
32
38
  when :monthly
33
- "#{@file_date.strftime('%Y-%m')}"
39
+ @file_date.strftime("%Y-%m").to_s
34
40
  else
35
- "#{@file_date.strftime('%Y-%m-%d')}"
41
+ @file_date.strftime("%Y-%m-%d").to_s
36
42
  end
37
43
  end
38
44
 
45
+ # Check if the file should be rolled.
46
+ #
47
+ # @return [Boolean]
39
48
  def roll_file?
40
49
  if @manual
41
50
  true
@@ -54,9 +63,9 @@ module Lumberjack
54
63
  end
55
64
  end
56
65
  end
57
-
66
+
58
67
  protected
59
-
68
+
60
69
  def after_roll
61
70
  @file_date = Date.today
62
71
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literals: true
2
2
 
3
- require 'fileutils'
3
+ require "fileutils"
4
4
 
5
5
  module Lumberjack
6
6
  class Device
@@ -10,23 +10,30 @@ module Lumberjack
10
10
 
11
11
  # The absolute path of the file being logged to.
12
12
  attr_reader :path
13
-
13
+
14
14
  # Create a logger to the file at +path+. Options are passed through to the Writer constructor.
15
+ #
16
+ # @param [String, Pathname] path The path to the log file.
17
+ # @param [Hash] options The options for the device.
15
18
  def initialize(path, options = {})
16
19
  @path = File.expand_path(path)
17
20
  FileUtils.mkdir_p(File.dirname(@path))
18
21
  super(file_stream, options)
19
22
  end
20
-
23
+
24
+ # Reopen the log file.
25
+ #
26
+ # @param [Object] logdev not used
27
+ # @return [void]
21
28
  def reopen(logdev = nil)
22
29
  close
23
30
  @stream = file_stream
24
31
  end
25
-
32
+
26
33
  private
27
-
34
+
28
35
  def file_stream
29
- File.new(@path, 'a', :encoding => EXTERNAL_ENCODING)
36
+ File.new(@path, "a", encoding: EXTERNAL_ENCODING)
30
37
  end
31
38
  end
32
39
  end
@@ -4,38 +4,39 @@ module Lumberjack
4
4
  class Device
5
5
  # This is a logging device that forward log entries to multiple other devices.
6
6
  class Multi < Device
7
+ # @param [Array<Lumberjack::Device>] devices The devices to write to.
7
8
  def initialize(*devices)
8
9
  @devices = devices.flatten
9
10
  end
10
-
11
+
11
12
  def write(entry)
12
13
  @devices.each do |device|
13
14
  device.write(entry)
14
15
  end
15
16
  end
16
-
17
+
17
18
  def flush
18
19
  @devices.each do |device|
19
20
  device.flush
20
21
  end
21
22
  end
22
-
23
+
23
24
  def close
24
25
  @devices.each do |device|
25
26
  device.close
26
27
  end
27
28
  end
28
-
29
+
29
30
  def reopen(logdev = nil)
30
31
  @devices.each do |device|
31
32
  device.reopen(logdev = nil)
32
33
  end
33
34
  end
34
-
35
+
35
36
  def datetime_format
36
37
  @devices.detect(&:datetime_format).datetime_format
37
38
  end
38
-
39
+
39
40
  def datetime_format=(format)
40
41
  @devices.each do |device|
41
42
  device.datetime_format = format
@@ -7,7 +7,7 @@ module Lumberjack
7
7
  class Null < Device
8
8
  def initialize(*args)
9
9
  end
10
-
10
+
11
11
  def write(entry)
12
12
  end
13
13
  end
@@ -14,35 +14,43 @@ module Lumberjack
14
14
  class RollingLogFile < LogFile
15
15
  attr_reader :path
16
16
  attr_accessor :keep
17
-
17
+
18
18
  def initialize(path, options = {})
19
19
  @path = File.expand_path(path)
20
20
  @keep = options[:keep]
21
21
  super(path, options)
22
- @file_inode = stream.lstat.ino rescue nil
22
+ @file_inode = begin
23
+ stream.lstat.ino
24
+ rescue
25
+ nil
26
+ end
23
27
  @@rolls = []
24
28
  @next_stat_check = Time.now.to_f
25
29
  @min_roll_check = (options[:min_roll_check] || 1.0).to_f
26
30
  end
27
-
31
+
28
32
  # Returns a suffix that will be appended to the file name when it is archived.. The suffix should
29
33
  # change after it is time to roll the file. The log file will be renamed when it is rolled.
30
34
  def archive_file_suffix
31
35
  raise NotImplementedError
32
36
  end
33
-
37
+
34
38
  # Return +true+ if the file should be rolled.
35
39
  def roll_file?
36
40
  raise NotImplementedError
37
41
  end
38
-
42
+
39
43
  # Roll the log file by renaming it to the archive file name and then re-opening a stream to the log
40
44
  # file path. Rolling a file is safe in multi-threaded or multi-process environments.
41
- def roll_file! #:nodoc:
45
+ def roll_file! # :nodoc:
42
46
  do_once(stream) do
43
47
  archive_file = "#{path}.#{archive_file_suffix}"
44
48
  stream.flush
45
- current_inode = File.stat(path).ino rescue nil
49
+ current_inode = begin
50
+ File.stat(path).ino
51
+ rescue
52
+ nil
53
+ end
46
54
  if @file_inode && current_inode == @file_inode && !File.exist?(archive_file) && File.exist?(path)
47
55
  begin
48
56
  File.rename(path, archive_file)
@@ -59,41 +67,49 @@ module Lumberjack
59
67
  end
60
68
 
61
69
  protected
62
-
70
+
63
71
  # This method will be called after a file has been rolled. Subclasses can
64
72
  # implement code to reset the state of the device. This method is thread safe.
65
73
  def after_roll
66
74
  end
67
-
75
+
68
76
  # Handle rolling the file before flushing.
69
77
  def before_flush # :nodoc:
70
78
  if @min_roll_check <= 0.0 || Time.now.to_f >= @next_stat_check
71
79
  @next_stat_check += @min_roll_check
72
- path_inode = File.lstat(path).ino rescue nil
80
+ path_inode = begin
81
+ File.lstat(path).ino
82
+ rescue
83
+ nil
84
+ end
73
85
  if path_inode != @file_inode
74
86
  @file_inode = path_inode
75
87
  reopen_file
76
- else
77
- roll_file! if roll_file?
88
+ elsif roll_file?
89
+ roll_file!
78
90
  end
79
91
  end
80
92
  end
81
-
93
+
82
94
  private
83
95
 
84
96
  def reopen_file
85
97
  old_stream = stream
86
- new_stream = File.open(path, 'a', encoding: EXTERNAL_ENCODING)
98
+ new_stream = File.open(path, "a", encoding: EXTERNAL_ENCODING)
87
99
  new_stream.sync = true if buffer_size > 0
88
- @file_inode = new_stream.lstat.ino rescue nil
100
+ @file_inode = begin
101
+ new_stream.lstat.ino
102
+ rescue
103
+ nil
104
+ end
89
105
  self.stream = new_stream
90
106
  old_stream.close
91
107
  end
92
108
  end
93
-
109
+
94
110
  def cleanup_files!
95
111
  if keep
96
- files = Dir.glob("#{path}.*").collect{|f| [f, File.ctime(f)]}.sort{|a,b| b.last <=> a.last}.collect{|a| a.first}
112
+ files = Dir.glob("#{path}.*").collect { |f| [f, File.ctime(f)] }.sort { |a, b| b.last <=> a.last }.collect { |a| a.first }
97
113
  if files.size > keep
98
114
  files[keep, files.length].each do |f|
99
115
  File.delete(f)
@@ -101,7 +117,7 @@ module Lumberjack
101
117
  end
102
118
  end
103
119
  end
104
-
120
+
105
121
  def do_once(file)
106
122
  begin
107
123
  file.flock(File::LOCK_EX)
@@ -110,11 +126,19 @@ module Lumberjack
110
126
  return
111
127
  end
112
128
  begin
113
- verify = file.lstat rescue nil
129
+ verify = begin
130
+ file.lstat
131
+ rescue
132
+ nil
133
+ end
114
134
  # Execute only if the file we locked is still the same one that needed to be rolled
115
135
  yield if verify && verify.ino == @file_inode && verify.size > 0
116
136
  ensure
117
- file.flock(File::LOCK_UN) rescue nil
137
+ begin
138
+ file.flock(File::LOCK_UN)
139
+ rescue
140
+ nil
141
+ end
118
142
  end
119
143
  end
120
144
  end