Sha256: 45d5c3c23b5c4d6b277311f50365ff793a97e1265024788270c716acb28771a3
Contents?: true
Size: 914 Bytes
Versions: 2
Compression:
Stored size: 914 Bytes
Contents
# coding: utf-8 require 'logger' module COS module Logging # 默认日志存储 DEFAULT_LOG_FILE = './cos-sdk.log' # 日志最大数量 MAX_NUM_LOG = 100 # 日志覆盖大小 ROTATE_SIZE = 10 * 1024 * 1024 # 设置日志输出的文件 # level = Logger::DEBUG | Logger::INFO | Logger::ERROR | Logger::FATAL def self.set_logger(file, level) if file == STDOUT or file == STDERR @logger = Logger.new(file) @logger.level = level else @logger = Logger.new(file, MAX_NUM_LOG, ROTATE_SIZE) @logger.level = level end end # 获取logger def logger Logging.logger end private # 实例方法使用logger def self.logger unless @logger @logger = Logger.new(DEFAULT_LOG_FILE, MAX_NUM_LOG, ROTATE_SIZE) @logger.level = Logger::INFO end @logger end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cos-0.1.2 | lib/cos/logging.rb |
cos-0.1.1 | lib/cos/logging.rb |