Class: Mongrel2::Config::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/mongrel2/config/log.rb

Overview

Mongrel2 configuration Log class

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.log_action(what, why = nil, where = nil, how = nil) ⇒ Object

Log an entry to the commit log with the given what, why, where, and how values and return it after it’s saved.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/mongrel2/config/log.rb', line 24

def self::log_action( what, why=nil, where=nil, how=nil )
	where ||= Socket.gethostname
	how ||= File.basename( $0 )

	who = Etc.getlogin

	return self.create(
		who:      who,
		what:     what,
		location: where,
		how:      how,
		why:      why
	)
end

Instance Method Details

#to_sObject

Stringify the log entry and return it.



73
74
75
76
77
78
# File 'lib/mongrel2/config/log.rb', line 73

def to_s
	# 2011-09-09 19:35:40 [who] @where how: what (why)
	msg = "%{happened_at} [%{who}] @%{location} %{how}: %{what}" % self.values
	msg += " (#{self.why})" if self.why
	return msg
end