Class: IoT::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/iot.rb

Overview

Logging events and actions

Instance Method Summary collapse

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 message(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