Skip to content

Commit

Permalink
Merge "Python support for log_file_size and log_file_count config"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jan 5, 2016
2 parents 3da10fd + ba409ea commit 34f76af
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions library/python/pysandesh/sandesh_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ def __init__(self, logger_name, logger_config_file=None):
def set_logging_params(self, enable_local_log=False, category='',
level=SandeshLevel.SYS_INFO, file=_DEFAULT_LOG_FILE,
enable_syslog=False, syslog_facility='LOG_LOCAL0',
enable_trace_print=False, enable_flow_log=False):
enable_trace_print=False, enable_flow_log=False,
maxBytes=5000000, backupCount=10):
self.set_local_logging(enable_local_log)
self.set_logging_category(category)
self.set_logging_level(level)
self.set_logging_file(file)
self.set_logging_file(file, maxBytes, backupCount)
self.set_logging_syslog(enable_syslog, syslog_facility)
self.set_trace_print(enable_trace_print)
self.set_flow_logging(enable_flow_log)
Expand Down Expand Up @@ -116,7 +117,7 @@ def set_logging_level(self, level):
super(SandeshLogger, self).set_logging_level(level)
# end set_logging_level

def set_logging_file(self, file):
def set_logging_file(self, file, maxBytes=5000000, backupCount=10):
if self.logging_file() != file:
self._logger.info('SANDESH: Logging: FILE: [%s] -> [%s]',
self.logging_file(), file)
Expand All @@ -126,7 +127,8 @@ def set_logging_file(self, file):
else:
self._logging_file_handler = (
logging.handlers.RotatingFileHandler(
filename=file, maxBytes=5000000, backupCount=10))
filename=file, maxBytes=maxBytes,
backupCount=backupCount))
log_format = logging.Formatter(
'%(asctime)s [%(name)s]: %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p')
Expand Down

0 comments on commit 34f76af

Please sign in to comment.