Skip to content

Commit

Permalink
Add environment variable to set log debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
chushenmeshile committed Aug 17, 2020
1 parent 9109686 commit 7e2f3b5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/aliyun/common/logging.rb
Expand Up @@ -38,10 +38,26 @@ def self.logger
@logger = Logger.new(
@log_file, MAX_NUM_LOG, ROTATE_SIZE)
@logger.level = Logger::INFO
set_env_log_level
end
@logger
end

def self.set_env_log_level
case ENV["ALIYUN_OSS_SDK_LOG_LEVEL"] && ENV["ALIYUN_OSS_SDK_LOG_LEVEL"].upcase
when "DEBUG"
@logger.level = Logger::DEBUG
when "WARN"
@logger.level = Logger::WARN
when "ERROR"
@logger.level = Logger::ERROR
when "FATAL"
@logger.level = Logger::FATAL
when "UNKNOWN"
@logger.level = Logger::UNKNOWN
end
end

end # logging
end # Common
end # Aliyun

0 comments on commit 7e2f3b5

Please sign in to comment.