Class: IoT::Log
- Inherits:
-
Object
- Object
- IoT::Log
- Defined in:
- lib/iot.rb
Overview
Logging events and actions
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
8 9 10 |
# File 'lib/iot.rb', line 8 def initialize(file_name='/tmp/iot.log') @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
13 14 15 16 17 |
# File 'lib/iot.rb', line 13 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 |