Module: Aliyun::Log::Common::Logging

Included in:
Protocol, Request
Defined in:
lib/aliyun/log/common/logging.rb

Constant Summary collapse

MAX_NUM_LOG =
100
ROTATE_SIZE =
10 * 1024 * 1024

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.log_file=(log_file) ⇒ Object



26
27
28
29
30
31
# File 'lib/aliyun/log/common/logging.rb', line 26

def self.log_file=(log_file)
  @logger = Logger.new(
    log_file, MAX_NUM_LOG, ROTATE_SIZE
  )
  @logger.level = Logging.logger_level
end

.log_level=(level) ⇒ Object

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



17
18
19
20
# File 'lib/aliyun/log/common/logging.rb', line 17

def self.log_level=(level)
  @logger_level = level
  Logging.logger.level = level
end

.loggerObject



38
39
40
41
42
43
44
45
46
# File 'lib/aliyun/log/common/logging.rb', line 38

def self.logger
  unless @logger
    @logger = Logger.new(
      @log_file ||= Config.log_file || IO::NULL, MAX_NUM_LOG, ROTATE_SIZE
    )
    @logger.level = Logging.logger_level
  end
  @logger
end

.logger=(logger) ⇒ Object



22
23
24
# File 'lib/aliyun/log/common/logging.rb', line 22

def self.logger=(logger)
  @logger = logger
end

.logger_levelObject



33
34
35
36
# File 'lib/aliyun/log/common/logging.rb', line 33

def self.logger_level
  @logger_level ||= Config.log_level
  @logger_level
end

Instance Method Details

#loggerObject



12
13
14
# File 'lib/aliyun/log/common/logging.rb', line 12

def logger
  Logging.logger
end