Sha256: 14a09a6d5e103c67e792f5fbb55ed2250083bacd2c1a600faa29ac8ec40f7a22
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
class Acs::Ldap::Logger < ::Logger def self.error(message) build.error(message) end def self.info(message) build.info(message) end def self.debug(message) build.debug(message) end 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 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 def self.build new(Rails.root.join("log", file_name)) end def self.file_name file_name_noext + '.log' end def format_message(severity, timestamp, progname, msg) "#{severity} : #{timestamp.strftime("%y-%m-%d %H:%M:%S:%L %z")} : #{msg}\n" end def self.archive %x(gzip -c #{file_path} > #{targz_file_path}) end def self.clear %x(echo > #{file_path}) end def self.size File.new(file_path).size end 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 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 def self.build # File.delete(file_path) self.new(file_path) end ########## def self.file_name_noext "acs_ldap" end def self.file_name file_name_no_ext + ".log" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acs-ldap-0.1.3 | lib/acs/ldap/logger.rb |