class Acs::Ldap::Logger
Public Class Methods
archive()
click to toggle source
# File lib/acs/ldap/logger.rb, line 40 def self.archive %x(gzip -c #{file_path} > #{targz_file_path}) end
build()
click to toggle source
# File lib/acs/ldap/logger.rb, line 28 def self.build new(Rails.root.join("log", file_name)) end
clear()
click to toggle source
# File lib/acs/ldap/logger.rb, line 44 def self.clear %x(echo > #{file_path}) end
debug(message)
click to toggle source
# File lib/acs/ldap/logger.rb, line 11 def self.debug(message) build.debug(message) end
error(message)
click to toggle source
# File lib/acs/ldap/logger.rb, line 3 def self.error(message) build.error(message) end
file_name()
click to toggle source
# File lib/acs/ldap/logger.rb, line 32 def self.file_name file_name_noext + '.log' end
file_name_noext()
click to toggle source
# File lib/acs/ldap/logger.rb, line 77 def self.file_name_noext "acs_ldap" end
file_path()
click to toggle source
# File lib/acs/ldap/logger.rb, line 61 def self.file_path if Rails.root.present? Rails.root.join("log", file_name).to_s else [Dir.pwd, "log", file_name].join("/").to_s end end
info(message)
click to toggle source
# File lib/acs/ldap/logger.rb, line 7 def self.info(message) build.info(message) end
read_latest()
click to toggle source
# File lib/acs/ldap/logger.rb, line 15 def self.read_latest path = Rails.root.join("log", file_name) self.build unless File.exist?(path) tail_output, _ = Manager::Popen.popen(%W(tail -n 2000 #{path})) tail_output.split("\n") end
read_latest_for(filename)
click to toggle source
# File lib/acs/ldap/logger.rb, line 22 def self.read_latest_for filename path = Rails.root.join("log", filename) tail_output, _ = Manager::Popen.popen(%W(tail -n 2000 #{path})) tail_output.split("\n") end
size()
click to toggle source
# File lib/acs/ldap/logger.rb, line 48 def self.size if File.exist?(file_path) File.new(file_path).size else 0 end end
targz_file_path()
click to toggle source
# File lib/acs/ldap/logger.rb, line 56 def self.targz_file_path targz_file_name = "#{file_name}-" + %x(date "+%Y%m%d_%H%M%S").gsub("\n", '') + ".gz" Rails.root.join("log", targz_file_name).to_s end
Public Instance Methods
format_message(severity, timestamp, progname, msg)
click to toggle source
# File lib/acs/ldap/logger.rb, line 36 def format_message(severity, timestamp, progname, msg) "#{severity} : #{timestamp.strftime("%y-%m-%d %H:%M:%S:%L %z")} : #{msg}\n" end