Class: Idcf::Cli::Lib::Util::CliLogger
- Inherits:
-
Object
- Object
- Idcf::Cli::Lib::Util::CliLogger
- Defined in:
- lib/idcf/cli/lib/util/cli_logger.rb
Overview
logger level: shwo LOG_METHODS
Constant Summary collapse
- LOG_METHODS =
%w[debug error fatal info unknown warn].freeze
Class Attribute Summary collapse
-
.current_path ⇒ Object
readonly
Returns the value of attribute current_path.
-
.logger ⇒ Object
readonly
Returns the value of attribute logger.
Class Method Summary collapse
-
.cleaning(o) ⇒ Object
logrotate file delete.
-
.delete ⇒ Object
open file delete.
- .log_instance ⇒ Object
- .log_paths ⇒ Object
- .method_missing(name, *args) ⇒ Object
- .respond_to_missing?(symbol, _include_prvate) ⇒ Boolean
Class Attribute Details
.current_path ⇒ Object (readonly)
Returns the value of attribute current_path.
14 15 16 |
# File 'lib/idcf/cli/lib/util/cli_logger.rb', line 14 def current_path @current_path end |
.logger ⇒ Object (readonly)
Returns the value of attribute logger.
14 15 16 |
# File 'lib/idcf/cli/lib/util/cli_logger.rb', line 14 def logger @logger end |
Class Method Details
.cleaning(o) ⇒ Object
logrotate file delete
39 40 41 42 43 44 45 46 |
# File 'lib/idcf/cli/lib/util/cli_logger.rb', line 39 def cleaning(o) paths = log_paths log_limit = Idcf::Cli::Lib::Configure.get_code_conf('log_limit', o).to_i return unless paths.size > log_limit paths.reverse[log_limit, paths.size].each do |f| File.unlink(f) end end |
.delete ⇒ Object
open file delete
31 32 33 34 35 36 |
# File 'lib/idcf/cli/lib/util/cli_logger.rb', line 31 def delete return nil unless output_log? path = log_path return nil unless File.exist?(path) File.unlink(path) end |
.log_instance ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/idcf/cli/lib/util/cli_logger.rb', line 17 def log_instance return nil unless output_log? return logger unless logger.nil? path = log_path @current_path = path Idcf::Cli::Lib::Util::CliFile.mkdir(path) Idcf::Cli::Lib::Util::CliFile.writable(path) if File.exist?(path) @logger = Logger.new(path) logger.level = Idcf::Cli::Conf::Const::LOG_LEVEL logger end |
.log_paths ⇒ Object
48 49 50 51 |
# File 'lib/idcf/cli/lib/util/cli_logger.rb', line 48 def log_paths dir_path = File.('..', log_path) Dir.glob("#{dir_path}/#{Idcf::Cli::Conf::Const::LOG_FILE_PREFIX}*") end |
.method_missing(name, *args) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/idcf/cli/lib/util/cli_logger.rb', line 57 def method_missing(name, *args) return super unless LOG_METHODS.index(name.to_s) arg = [args[0]] arg << args[1] unless args[1].nil? add(name, *arg) end |
.respond_to_missing?(symbol, _include_prvate) ⇒ Boolean
53 54 55 |
# File 'lib/idcf/cli/lib/util/cli_logger.rb', line 53 def respond_to_missing?(symbol, _include_prvate) LOG_METHODS.index(symbol.to_s) ? true : false end |