Class: Reedb::DaemonLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/reedb/utils/logger.rb

Constant Summary collapse

@@logger =
nil

Class Method Summary collapse

Class Method Details

.setup(path) ⇒ Object

Sets up a logger on a vault and loads existing logs if they exist. Logs are limited not in size but only by dates. Vault logs don’t contain whitespaces.



65
66
67
68
# File 'lib/reedb/utils/logger.rb', line 65

def self.setup(path)
	log_path = "#{path}/#{Reedb::Utilities.get_time(true)}.log"
	@@logger = Logger.new("#{log_path}")
end

.write(message, level = "") ⇒ Object

Writes something to the current vault log (under #@path/logs/) Possible parameters are:

‘debug’

Throwing every operation at the log.

‘info’

Default logging level for most situations and events.

‘warn’

Logs a warning. Should be event that won’t impact stability.

‘error’

Logs an error. Should be recoverable event.

‘fatal’

Logs a fatal crash. Should make the Reepass daemon crash!



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/reedb/utils/logger.rb', line 78

def self.write(message, level = "")
	if level == "warn"
		@@logger.warn(message)

	elsif level == "debug"
		@@logger.debug(message)

	elsif level == "error"
		@@logger.error(message)

	elsif level == "fatal"
		@@logger.fatal(message)
		
	else
		@@logger.info(message)
	end
end