rails-cron-logger 1.0.0 → 1.0.1

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.
data/README.md CHANGED
@@ -22,4 +22,8 @@ Example:
22
22
 
23
23
  1 * * * * rails runner '$stdout.sync = true; <your code here>'
24
24
 
25
- Setting `$stdout.sync = true` in this gem seems like it would be a bit overreaching.
25
+ Setting `$stdout.sync = true` in this gem seems a bit overreaching, but for convenience if you pass `:sync => true` to Logger.new then rails-cron-logger will perform this step for you.
26
+
27
+ Example:
28
+
29
+ logger = RailsCronLogger::Logger.new(:sync => true)
@@ -3,7 +3,16 @@ require 'rails-cron-logger/version'
3
3
 
4
4
  module RailsCronLogger
5
5
  class Logger < Logger
6
- def initialize
6
+ def initialize(options={})
7
+ if options[:sync]
8
+ # Flushes output on every write to avoid losing valuable output if the cron job crashes, etc.
9
+ # see http://coderrr.wordpress.com/2008/12/20/automatically-flushing-redirected-or-piped-stdout/
10
+ # Note that this is obviously an interpreter-wide setting we're changing here.
11
+ # Really this ought to be set at a higher level than the code calling this logger (in the crontab
12
+ # or in the crontab script that calls your code perhaps) but adding an option here for convenience.
13
+ $stdout.sync = true
14
+ end
15
+
7
16
  logdev = if Rails.env.test?
8
17
  # don't want log messages for tests mixed in with test output
9
18
  Rails.application.config.paths.log.first
@@ -1,7 +1,7 @@
1
1
  module Rails
2
2
  module Cron
3
3
  module Logger
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-cron-logger
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jordan Brough