Class: Reedb::VaultLogger

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

Overview

A logger that gets bound to a vault and logs vault activity in the vaults logs/ directory. It’s using the Ruby internal logging library to split up logs into date blocks. (Each day is one log file).

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.



26
27
28
29
# File 'lib/reedb/utils/logger.rb', line 26

def self.setup(path)
	log_path = "#{path}/logs/#{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!



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/reedb/utils/logger.rb', line 39

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