Class: IoT::Log
- Inherits:
-
Object
- Object
- IoT::Log
- Defined in:
- lib/iot.rb
Overview
Logging events and actions
Instance Attribute Summary collapse
-
#file_name ⇒ Object
Returns the value of attribute file_name.
Instance Method Summary collapse
-
#initialize(file_name = '/tmp/iot.log') ⇒ Log
constructor
A new instance of Log.
-
#message(type = 'I', text = 'OK') ⇒ Object
Message types: I = Info, W = Warning, E = Error, F = Fatal error.
Constructor Details
#initialize(file_name = '/tmp/iot.log') ⇒ Log
Returns a new instance of Log.
10 11 12 |
# File 'lib/iot.rb', line 10 def initialize(file_name='/tmp/iot.log') @file_name = file_name end |
Instance Attribute Details
#file_name ⇒ Object
Returns the value of attribute file_name.
8 9 10 |
# File 'lib/iot.rb', line 8 def file_name @file_name end |
Instance Method Details
#message(type = 'I', text = 'OK') ⇒ Object
Message types: I = Info, W = Warning, E = Error, F = Fatal error
15 16 17 18 19 |
# File 'lib/iot.rb', line 15 def (type='I', text='OK') File.open(@file_name, 'w+') do |log| log.printf "%s %s %s\n", Time.now.strftime("%Y%m%d %H%M%S"), type, text end end |