Module: ProcessWanker::Log

Constant Summary collapse

DEBUG =
0
INFO =
1
WARN =
2
ERROR =
3
@@mutex =
Mutex.new
@@level =
INFO

Class Method Summary collapse

Class Method Details

.debug(msg) ⇒ Object



78
79
80
# File 'lib/log.rb', line 78

def debug(msg)
	log(msg,DEBUG)
end

.error(msg) ⇒ Object



66
67
68
# File 'lib/log.rb', line 66

def error(msg)
	log(msg,ERROR)
end

.info(msg) ⇒ Object



74
75
76
# File 'lib/log.rb', line 74

def info(msg)
	log(msg,INFO)
end

.log(msg, level = INFO) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/log.rb', line 51

def log(msg,level=INFO)
	return unless(level >= @@level)
	@@mutex.synchronize do
		STDOUT.puts "[#{level}] [#{Time.new}] #{msg}"
      STDOUT.flush
	end
end

.set_level(level) ⇒ Object



40
41
42
# File 'lib/log.rb', line 40

def set_level(level)
	@@level=level
end

.warn(msg) ⇒ Object



70
71
72
# File 'lib/log.rb', line 70

def warn(msg)
	log(msg,WARN)
end