Class: Logoris
- Inherits:
-
Object
- Object
- Logoris
- Defined in:
- lib/logoris.rb
Constant Summary collapse
- VERSION =
"1.0.0"
Instance Attribute Summary collapse
-
#error_file ⇒ String
The optional error_file to log stderr events.
-
#log_file ⇒ String
The optional error_file to log both stdout and stderr events.
-
#out_file ⇒ String
The optional out_file to log stdout events.
Instance Method Summary collapse
- #error(message) ⇒ void
- #initialize(args = {}) ⇒ void constructor
- #log_exists?(file) ⇒ Boolean
- #out(message) ⇒ void
- #to_log(file, message) ⇒ void
Constructor Details
#initialize(args = {}) ⇒ void
21 22 23 24 25 26 27 28 |
# File 'lib/logoris.rb', line 21 def initialize(args={}) @out_file = false # Do not log stdout events to a file by default. @error_file = false # Do not log stderr events to a file by default. @log_file = false # Do not log both stdout and stderr events to a file by default. out_file = args[:out_file] if args[:out_file] # Set file for stdout, if given. error_file = args[:error_file] if args[:error_file] # Set file for stderr, if given. log_file = args[:log_file] if args[:log_file] # Set file for stdout and stderr, if given. end |
Instance Attribute Details
#error_file ⇒ String
The optional error_file to log stderr events.
11 12 13 |
# File 'lib/logoris.rb', line 11 def error_file @error_file end |
#log_file ⇒ String
The optional error_file to log both stdout and stderr events.
15 16 17 |
# File 'lib/logoris.rb', line 15 def log_file @log_file end |
#out_file ⇒ String
The optional out_file to log stdout events.
7 8 9 |
# File 'lib/logoris.rb', line 7 def out_file @out_file end |
Instance Method Details
#error(message) ⇒ void
This method returns an undefined value.
40 41 42 43 44 |
# File 'lib/logoris.rb', line 40 def error() STDERR.puts to_log(@error_file, ) if @error_file to_log(@log_file, ) if @log_file end |
#log_exists?(file) ⇒ Boolean
77 78 79 |
# File 'lib/logoris.rb', line 77 def log_exists?(file) File.exists?(file) end |
#out(message) ⇒ void
This method returns an undefined value.
32 33 34 35 36 |
# File 'lib/logoris.rb', line 32 def out() STDOUT.puts to_log(@out_file, ) if @out_file to_log(@log_file, ) if @log_file end |
#to_log(file, message) ⇒ void
This method returns an undefined value.
70 71 72 73 |
# File 'lib/logoris.rb', line 70 def to_log(file, ) File.open(file, 'a') { |f| f.puts } to_log(@log_file, ) if @log_file end |