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 authored and huiguangjun committed Aug 17, 2020
1 parent 9109686 commit d0a0232
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/aliyun/common/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,27 @@ def self.logger
@log_file ||= ENV["ALIYUN_OSS_SDK_LOG_PATH"]
@logger = Logger.new(
@log_file, MAX_NUM_LOG, ROTATE_SIZE)
@logger.level = Logger::INFO
@logger.level = get_env_log_level || Logger::INFO
end
@logger
end

def self.get_env_log_level
return unless ENV["ALIYUN_OSS_SDK_LOG_LEVEL"]
case ENV["ALIYUN_OSS_SDK_LOG_LEVEL"].upcase
when "DEBUG"
Logger::DEBUG
when "WARN"
Logger::WARN
when "ERROR"
Logger::ERROR
when "FATAL"
Logger::FATAL
when "UNKNOWN"
Logger::UNKNOWN
end
end

end # logging
end # Common
end # Aliyun

0 comments on commit d0a0232

Please sign in to comment.