示例#1
0
 def __init__(self,
               filename,
               mode='a',
               maxBytes=0,
               encoding=None,
               delay=False,
               account_name=None,
               account_key=None,
               protocol='https',
               container='logs',
               zip_compression=False,
               max_connections=1,
               max_retries=5,
               retry_wait=1.0):
     meta = {'hostname': gethostname(), 'process': os.getpid()}
     RotatingFileHandler.__init__(self,
                                  filename % meta,
                                  mode=mode,
                                  maxBytes=maxBytes,
                                  backupCount=1,
                                  encoding=encoding,
                                  delay=delay)
     _BlobStorageFileHandler.__init__(self,
                                      account_name,
                                      account_key,
                                      protocol,
                                      container,
                                      zip_compression,
                                      max_connections,
                                      max_retries,
                                      retry_wait)
示例#2
0
 def __init__(self,
               filename,
               mode='a',
               maxBytes=0,
               encoding=None,
               delay=False,
               account_name=None,
               account_key=None,
               protocol='https',
               container='logs',
               zip_compression=False,
               max_connections=1,
               max_retries=5,
               retry_wait=1.0,
               is_emulated=False):
     meta = {'hostname': gethostname(), 'process': os.getpid()}
     RotatingFileHandler.__init__(self,
                                  filename % meta,
                                  mode=mode,
                                  maxBytes=maxBytes,
                                  backupCount=1,
                                  encoding=encoding,
                                  delay=delay)
     _BlobStorageFileHandler.__init__(self,
                                      account_name=account_name,
                                      account_key=account_key,
                                      protocol=protocol,
                                      container=container,
                                      zip_compression=zip_compression,
                                      max_connections=max_connections,
                                      max_retries=max_retries,
                                      retry_wait=retry_wait,
                                      is_emulated=is_emulated)
    def __init__(
        self,
        filename: str,
        mode: Optional[str] = 'a',
        maxBytes: Optional[int] = 0,
        backupCount: Optional[int] = 0,
        encoding: Optional[str] = None,
        delay: Optional[bool] = False,
    ):
        """Customize RotatingFileHandler to create full log path.

        Args:
            filename: The name of the logfile.
            mode: The write mode for the file.
            maxBytes: The max file size before rotating.
            backupCount: The maximum # of backup files.
            encoding: The log file encoding.
            delay: If True, then file opening is deferred until the first call to emit().
        """
        if encoding is None and os.getenv('LANG') is None:
            encoding = 'UTF-8'
        if not os.path.exists(os.path.dirname(filename)):
            os.makedirs(os.path.dirname(filename), exist_ok=True)
        RotatingFileHandler.__init__(self, filename, mode, maxBytes, backupCount, encoding, delay)

        # set namer
        self.namer = self.custom_gzip_namer
        self.rotator = self.custom_gzip_rotator
示例#4
0
 def __init__(self,
              filename,
              mode='a',
              maxBytes=0,
              backupCount=0,
              encoding=None,
              delay=False,
              when='h',
              interval=1,
              utc=False,
              atTime=None):
     """ Combines RotatingFileHandler TimedRotatingFileHandler)  """
     RotatingFileHandler.__init__(self,
                                  filename=filename,
                                  mode=mode,
                                  maxBytes=maxBytes,
                                  backupCount=backupCount,
                                  encoding=encoding,
                                  delay=delay)
     TimedRotatingFileHandler.__init__(self,
                                       filename=filename,
                                       when=when,
                                       interval=interval,
                                       backupCount=backupCount,
                                       encoding=encoding,
                                       delay=delay,
                                       utc=utc,
                                       atTime=atTime)
示例#5
0
    def __init__(self,
                 filename,
                 mode='a',
                 max_bytes=0,
                 backup_count=0,
                 encoding=None,
                 delay=False,
                 when='h',
                 interval=1,
                 utc=False):
        TimedRotatingFileHandler.__init__(self,
                                          filename=filename,
                                          when=when,
                                          interval=interval,
                                          backupCount=backup_count,
                                          encoding=encoding,
                                          delay=delay,
                                          utc=utc)

        RotatingFileHandler.__init__(self,
                                     filename=filename,
                                     mode=mode,
                                     maxBytes=max_bytes,
                                     backupCount=backup_count,
                                     encoding=encoding,
                                     delay=delay)
示例#6
0
 def __init__(self, *args, **kwargs):
     RotatingFileHandler.__init__(self, *args, **kwargs)
     self.last_record = None
     self.count_repeat = 0
     self.thread_messages = {}
     self.thread_lock = Lock()
     self.lock = None
     self.main_thread = threading.current_thread()
示例#7
0
 def __init__(self, *args, **kws):
 
     try:
         self.compress_cls = gzip
     except KeyError:
         raise ValueError('gzip compression method is not supported.')
     
     RotatingFileHandler.__init__(self, *args, **kws)
示例#8
0
 def __init__(self,
              filename,
              maxBytes,
              backupCount,
              mode='a',
              encoding=None,
              delay=0):
     RotatingFileHandler.__init__(self, filename, maxBytes, backupCount)
 def __init__(self, folder_max_size=None, *args, **kwargs):
     """
     :param folder_max_size: max size folder should use
     :param args:
     :param kwargs:
     """
     RotatingFileHandler.__init__(self, *args, **kwargs)
     self._folder_max_size = folder_max_size
     self._log_folder = os.path.dirname(self.baseFilename)
示例#10
0
	def __init__(self , filename , mode='a' , maxBytes=0, backupCount=0, encoding=None):
		self.current = time.strftime("%Y%m%d" , time.localtime(time.time()))
		self.path = os.path.dirname(filename)
		self.filename = os.path.basename(filename)
		newdir = os.path.join(self.path , self.current)
		if not os.access(newdir , os.X_OK):
			os.mkdir(newdir)
		newfile = os.path.join(newdir , self.filename)
		RotatingFileHandler.__init__(self, newfile , mode, maxBytes , backupCount , encoding)
示例#11
0
  def __init__(self, *args, **kws):
    compress_mode = kws.pop('compress_mode')

    try:
        self.compress_cls = COMPRESSION_SUPPORTED[compress_mode]
    except KeyError:
        raise ValueError('"%s" compression method not supported.' % compress_mode)
     
    RotatingFileHandler.__init__(self, *args, **kws)
示例#12
0
文件: app.py 项目: panstav1/tng-dsm
 def __init__(self,
              filename,
              maxBytes,
              backupCount,
              mode='a',
              encoding=None,
              delay=0):
     mkdir_p(os.path.dirname(filename))
     RotatingFileHandler.__init__(self, filename, maxBytes, backupCount)
示例#13
0
 def __init__(self,
              filename,
              mode='a',
              max_bytes=0,
              backup_count=0,
              encoding=None,
              delay=False):
     RotatingFileHandler.__init__(self, filename, mode, max_bytes,
                                  backup_count, encoding, delay)
示例#14
0
    def __init__(self, filename, when = 'h', interval = 1, backupCount = 0,
                 encoding = None, delay = False, utc = False, atTime = None,
                 mode = 'a', maxBytes=0):

        TimedRotatingFileHandler.__init__(self, filename, when, interval,
                                              backupCount, encoding, delay,
                                              utc, atTime)
        RotatingFileHandler.__init__(self, filename, mode, maxBytes,
                                     backupCount, encoding, delay)
示例#15
0
    def __init__(self, filename, mode='a', maxBytes=0,   
                       backupCount=0, encoding=None, delay=0,
                       aws_key = None, aws_secret = None,
                       aws_urlbase = None):

        RotatingFileHandler.__init__(self, filename, mode, maxBytes, backupCount, encoding, delay)
        self.aws_key = aws_key
        self.aws_secret = aws_secret
        self.aws_urlbase = aws_urlbase
示例#16
0
    def __init__(self, filename, header, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=False):
        self._header = header
        self._file_pre_exist = os.path.exists(filename)

        RotatingFileHandler.__init__(self, filename, mode, maxBytes, backupCount, encoding, delay)

        # Write the header if delay is False and a file stream was created.
        if not delay and self.stream is not None:
            self.stream.write('%s\n' % header)
示例#17
0
    def __init__(self):
        RotatingFileHandler.__init__(
            self, os.path.join(path, "logs", "r2tg_bot.log"))
        self.backupCount = 5
        self.encoding = "UTF-8"
        self.maxBytes = 5_000_000

        datefmt = "%Y-%m-%d %H:%M:%S"
        fmt = "[%(asctime)s][%(levelname)s] - %(message)s"
        self.setFormatter(logging.Formatter(fmt, datefmt))
 def __init__(self,
              filename,
              mode='a',
              maxBytes=0,
              backupCount=0,
              encoding=None,
              delay=0):
     self.backup_count = backupCount
     RotatingFileHandler.__init__(self, filename, mode, maxBytes,
                                  backupCount, encoding, delay)
示例#19
0
 def __init__(self,
              filename,
              mode='a',
              maxBytes=0,
              backupCount=0,
              encoding=None,
              delay=0):
     filename = _relativeToLogPath(filename)
     RotatingFileHandler.__init__(self, filename, mode, maxBytes,
                                  backupCount, encoding, delay)
示例#20
0
 def __init__(self,
              filename,
              mode='a',
              maxBytes=0,
              backupCount=0,
              encoding=None,
              delay=False):
     os.makedirs(os.path.dirname(filename), exist_ok=True)
     RotatingFileHandler.__init__(self, filename, mode, maxBytes,
                                  backupCount, encoding, delay)
示例#21
0
    def __init__(self, filename, maxBytes=0, backupCount=0, delay=False, compression=None):
        RotatingFileHandler.__init__(self, filename, maxBytes=maxBytes, backupCount=backupCount, delay=delay)

        self.compression = compression
        self.compressor = None

        log_dir, log_name = os.path.split(self.baseFilename)
        self.log_pattern = re.compile("^{}(?:|\.(\d+)(?:|\.gz|\.xz))$".format(log_name))

        file_indexes = [idx for name, idx in self._log_files()]
        self.max_index = max(file_indexes) if file_indexes else 0
示例#22
0
 def __init__(self, filename, mode="a", maxBytes=0, backupCount=0, encoding=None):
     """
     :param str filename: Name of of the log file.
     :param str mode: Mode to open the file, should be  "w" or "a". Defaults to "a"
     :param int maxBytes: Maximum file size before rollover. By default, rollover never happens.
     :param int backupCount: Number of backups to make. Defaults to 0.
     :param encoding: Encoding to use when writing to the file. Defaults to None.
         File will be opened by default.
     """
     RotatingFileHandler.__init__(self, filename, mode, maxBytes, backupCount, encoding)
     self._disable_rollover = False
示例#23
0
 def __init__(self, filename, mode="a", maxBytes=0, backupCount=0, encoding=None):
     """
     :param str filename: Name of of the log file.
     :param str mode: Mode to open the file, should be  "w" or "a". Defaults to "a"
     :param int maxBytes: Maximum file size before rollover. By default, rollover never happens.
     :param int backupCount: Number of backups to make. Defaults to 0.
     :param encoding: Encoding to use when writing to the file. Defaults to None.
         File will be opened by default.
     """
     RotatingFileHandler.__init__(self, filename, mode, maxBytes, backupCount, encoding)
     self._disable_rollover = False
示例#24
0
 def __init__(self,
              filename: str,
              mode: str = "a",
              maxBytes: int = 0,
              backupCount: int = 0,
              encoding: str = None,
              delay: bool = False):
     RotatingFileHandler.__init__(self,
                                  filename,
                                  maxBytes=maxBytes,
                                  backupCount=backupCount)
示例#25
0
 def __init__(self,
              filename,
              max_size=DEFAULT_LOGSIZE,
              backup_count=2,
              logpath=DEFAULT_LOGPATH,
              mode='a',
              encoding=None,
              delay=0):
     _make_dir(os.path.dirname(filename), logpath)
     RotatingFileHandler.__init__(self, filename, mode, max_size,
                                  backup_count, encoding, delay)
 def __init__(self,
              filename,
              mode='a',
              maxBytes=0,
              backupCount=0,
              encoding=None,
              delay=False):
     Path(const.LOG_FOLDER_PATH).mkdir(exist_ok=True)
     log_path = const.LOG_FOLDER_PATH / filename
     RotatingFileHandler.__init__(self, log_path, mode, maxBytes,
                                  backupCount, encoding, delay)
示例#27
0
 def __init__(self, filename, mode='a', maxBytes=1048576, backupCount=5,
              encoding=None, delay=0):
     try:
         path = os.path.split(filename)[0]
         # will fail on python2, we only support python3
         os.makedirs(path, exist_ok=True)
     except Exception as err:
         print('Could not create logfile at %s: %s' % (path, err))
         sys.exit(1)
     RotatingFileHandler.__init__(self, filename, mode, maxBytes,
                                  backupCount, encoding, delay)
示例#28
0
文件: mytools.py 项目: dsgdtc/daemon
    def __init__(self, filename, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=0, compression=None):
        """%s


        """ % RotatingFileHandler.__doc__

        RotatingFileHandler.__init__(self, filename=filename, mode=mode, maxBytes=maxBytes,
                                     backupCount=backupCount, encoding=encoding, delay=delay)
        if compression not in (None, '.gz'):
            raise ValueError("Only '.gz' compression is supported.")
        self._compression = compression
示例#29
0
 def __init__(self, filename, maxBytes=0, logsCount=1, file_name_prefix=''):
     self._logs_count = logsCount
     self._old_logs_count = self._logs_count
     self._enabled = True
     self._logging_lock = RLock()
     RotatingFileHandler.__init__(self,
                                  filename,
                                  maxBytes=maxBytes,
                                  backupCount=1,
                                  encoding='utf-8')
     self.maxBytes = maxBytes
     self._file_name_prefix = file_name_prefix
示例#30
0
 def __init__(self, name):
     """
     Name is the log file name.
     """
     RotatingFileHandler.__init__(self,
                                  filename=name,
                                  mode='a',
                                  maxBytes=5 * 1024 * 1024,
                                  backupCount=2,
                                  encoding=None,
                                  delay=0)
     QObject.__init__(self)
示例#31
0
文件: logger.py 项目: fspaolo/code
    def __init__(self, path, maxBytes=1000000, backupCount=3, level=None,
        formatter=None):
        RotatingFileHandler.__init__(
            self, path, maxBytes=maxBytes, backupCount=3
        )

        if level is None:
            level = LEVEL
        if formatter is None:
            formatter = FORMATTER
        # Set our default formatter and log level.
        self.setFormatter(formatter)
        self.setLevel(level)
示例#32
0
    def __init__(self, path, maxBytes=1000000, backupCount=3, level=None,
        formatter=None):
        RotatingFileHandler.__init__(
            self, path, maxBytes=maxBytes, backupCount=3
        )

        if level is None:
            level = LEVEL
        if formatter is None:
            formatter = FORMATTER
        # Set our default formatter and log level.
        self.setFormatter(formatter)
        self.setLevel(level)
示例#33
0
 def __init__(self, filename, maxBytes, backupCount):
     RotatingFileHandler.__init__(self,
                                 filename, 
                                 maxBytes = maxBytes, 
                                 backupCount = backupCount)
     # Following snippett taken from WatchedFileHandler in Python 2.6.
     # Essentially, we need a hybrid between a RotatingFileHandler
     # and a WatchedFileHandler since we may have multiple rotaters all
     # logging to the same file.
     if not os.path.exists(self.baseFilename):
         self.dev, self.ino = -1, -1
     else:
         stat = os.stat(self.baseFilename)
         self.dev, self.ino = stat[ST_DEV], stat[ST_INO]
示例#34
0
    def __init__(self, filename, mode="a", maxBytes=0, backupCount=0,
                 encoding="utf-8", delay=0, rotlock=None):
        """ConcurrentRotatingFileHandler has one additinal keyword argument
        comparing to RotatingFileHandler - rotlock.

        :param rotlock: object used for locking, Lockf can be used
        :type rotlock: should provide acquire(block=True) and release methods
        """
        self.delay = delay # python 2.6 compatibility
        RotatingFileHandler.__init__(self, filename,
            mode=mode, maxBytes=maxBytes, backupCount=backupCount,
            encoding=encoding, delay=delay)
        self._rotlock = rotlock
        if self._rotlock is None:
            self._rotlock = multiprocessing.Lock()
示例#35
0
    def __init__(self,              \
                 filename,          \
                 mode        ='a',  \
                 maxBytes    = 0,   \
                 backupCount = 0,   \
                 encoding    = None,\
                 delay=0, when='h', interval=1, utc=False):
        TimedRotatingFileHandler.__init__( \
                self, filename=filename, when=when, interval=interval, \
                backupCount=backupCount, encoding=encoding, delay=delay,\
                utc=utc)

        RotatingFileHandler.__init__( \
                self, filename=filename, mode=mode, maxBytes=maxBytes, \
                backupCount=backupCount, encoding=encoding, delay=delay)
示例#36
0
 def __init__(self,
              filename,
              mode='a',
              maxBytes=0,
              backupCount=0,
              encoding=None,
              delay=0):
     """
     Open the specified file and use it as the stream for logging.
     """
     RotatingFileHandler.__init__(self, filename, mode, maxBytes,
                                  backupCount, encoding, delay)
     self.baseFilename = filename
     self.mode = mode
     self.backupCount = backupCount
示例#37
0
    def __init__(self,
                 filename,
                 mode='a',
                 maxBytes=0,
                 backupCount=0,
                 encoding=None,
                 delay=0,
                 aws_key=None,
                 aws_secret=None,
                 aws_urlbase=None):

        RotatingFileHandler.__init__(self, filename, mode, maxBytes,
                                     backupCount, encoding, delay)
        self.aws_key = aws_key
        self.aws_secret = aws_secret
        self.aws_urlbase = aws_urlbase
示例#38
0
    def __init__(self,
                 filename,
                 email,
                 password,
                 to,
                 subject,
                 mode='a',
                 maxBytes=0,
                 backupCount=0,
                 encoding=None,
                 delay=0):
        """
        Open the specified file and use it as the stream for logging.

        By default, the file grows indefinitely. You can specify particular
        values of maxBytes and backupCount to allow the file to rollover at
        a predetermined size.

        Rollover occurs whenever the current log file is nearly maxBytes in
        length. If backupCount is >= 1, the system will successively create
        new files with the same pathname as the base file, but with extensions
        ".1", ".2" etc. appended to it. For example, with a backupCount of 5
        and a base file name of "app.log", you would get "app.log",
        "app.log.1", "app.log.2", ... through to "app.log.5". The file being
        written to is always "app.log" - when it gets filled up, it is closed
        and renamed to "app.log.1", and if files "app.log.1", "app.log.2" etc.
        exist, then they are renamed to "app.log.2", "app.log.3" etc.
        respectively.

        If maxBytes is zero, rollover never occurs.
        """
        # If rotation/rollover is wanted, it doesn't make sense to use another
        # mode. If for example 'w' were specified, then if there were multiple
        # runs of the calling application, the logs from previous runs would be
        # lost if the 'w' is respected, because the log file would be truncated
        # on each run.
        if maxBytes > 0:
            mode = 'a'
        RotatingFileHandler.__init__(self, filename, mode, maxBytes,
                                     backupCount, encoding, delay)
        self.email = email
        self.password = password
        self.to = to
        self.subject = subject
        self.maxBytes = maxBytes
        self.backupCount = backupCount
示例#39
0
 def __init__(self, *args, **kwargs):
     RotatingFileHandler.__init__(self, *args, **kwargs)
     self.doRollover()
    def __init__(self, filename, mode='a', maxBytes=0, backupCount=0,
                 encoding=None):
		self._index = 0;
		self._lock = RLock()
		self._p = re.compile("(_\d*){0,1}(_\d*){0,1}(\.\w*){0,1}$", re.IGNORECASE)
		RotatingFileHandler.__init__(self, filename, mode, maxBytes, backupCount, encoding)
示例#41
0
文件: __main__.py 项目: c4rlo/darbup
 def __init__(self, filename, **kwargs):
     self.__doneInitialRollover = not os.path.exists(filename)
     RotatingFileHandler.__init__(self, filename, **kwargs)
示例#42
0
 def __init__(self, filename, **kw):
     self.filename = filename
     RotatingFileHandler.__init__(self, filename, **kw)
示例#43
0
 def __init__(self, filename, mode='a', maxBytes=0, encoding=None, delay=0):
     self._original_file = filename
     self._update_filename()
     RotatingFileHandler.__init__(self, filename, mode, maxBytes, 0, encoding, delay)
示例#44
0
 def __init__(self, filename, mode='a', max_bytes=0, backup_count=0, encoding=None, delay=False):
     RotatingFileHandler.__init__(self, filename, mode, max_bytes, backup_count, encoding, delay)
示例#45
0
 def __init__(self, filename, mode='a', maxBytes=0, backupCount=0,
              encoding=None, delay=False):
     RotatingFileHandler.__init__(
         self, filename, mode=mode, maxBytes=maxBytes,
         backupCount=backupCount, encoding=encoding, delay=delay)
     self.rotator = self._rotator
示例#46
0
 def __init__(self, *args, **kw):
     _RotatingFileHandler.__init__(self, *args, **kw)
     self._wr = weakref.ref(self, _remove_from_reopenable)
     _reopenable_handlers.append(self._wr)
 def __init__(self, filename, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=0):
     self.backup_count = backupCount
     RotatingFileHandler.__init__(self, filename, mode, maxBytes, backupCount, encoding, delay)
 def __init__(self, filename, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=0):
     dir = os.path.dirname(filename)
     if not os.path.exists(dir):
         os.makedirs(dir)
     #self._clean_directory(filename)
     RotatingFileHandler.__init__(self, filename, mode, maxBytes, backupCount, encoding, delay)
示例#49
0
 def __init__(self, filename, *args, **kwargs):
     self.filename = filename
     kwargs['delay'] = True    
     RotatingFileHandler.__init__(self, "/dev/null", *args, **kwargs)
示例#50
0
文件: filestuff.py 项目: rmlopes/code
 def __init__(self, filename):
         RotatingFileHandler.__init__(self, filename, 'w',0,0)
示例#51
0
 def __init__(self, filename, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=0):
     filename = _relativeToLogPath(filename)
     RotatingFileHandler.__init__(self, filename, mode, maxBytes, backupCount, encoding, delay)