Module: Aliyun::Common::Logging

Overview

Logging support

Examples:

include Logging
logger.info(xxx)

Constant Summary collapse

DEFAULT_LOG_FILE =
"./aliyun_sdk.log"
MAX_NUM_LOG =
100
ROTATE_SIZE =
10 * 1024 * 1024

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.loggerObject (private)


35
36
37
38
39
40
41
42
# File 'lib/aliyun/common/logging.rb', line 35

def self.logger
  unless @logger
    @logger = Logger.new(
      @log_file ||= DEFAULT_LOG_FILE, MAX_NUM_LOG, ROTATE_SIZE)
    @logger.level = Logger::INFO
  end
  @logger
end

.set_log_file(file) ⇒ Object

设置日志输出的文件


24
25
26
# File 'lib/aliyun/common/logging.rb', line 24

def self.set_log_file(file)
  @log_file = file
end

.set_log_level(level) ⇒ Object

level = Logger::DEBUG | Logger::INFO | Logger::ERROR | Logger::FATAL


19
20
21
# File 'lib/aliyun/common/logging.rb', line 19

def self.set_log_level(level)
  Logging.logger.level = level
end

Instance Method Details

#loggerObject

获取logger


29
30
31
# File 'lib/aliyun/common/logging.rb', line 29

def logger
  Logging.logger
end