Skip to content

Commit

Permalink
Merge pull request #1871 from fishtown-analytics/fix/log-rotation
Browse files Browse the repository at this point in the history
rotate the file at 10mb instead of by date
  • Loading branch information
beckjake authored Oct 29, 2019
2 parents 3a030ab + 78115cf commit 76dc41b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions core/dbt/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,15 @@ def make_record(self, message, exception, filename, lineno):
_redirect_std_logging()


class DelayedFileHandler(logbook.TimedRotatingFileHandler, FormatterMixin):
class DelayedFileHandler(logbook.RotatingFileHandler, FormatterMixin):
def __init__(
self,
log_dir: Optional[str] = None,
level=logbook.DEBUG,
filter=None,
bubble=True,
max_size=10 * 1024 * 1024, # 10 mb
backup_count=5,
) -> None:
self.disabled = False
self._msg_buffer: Optional[List[logbook.LogRecord]] = []
Expand All @@ -352,6 +354,8 @@ def __init__(
if log_dir is not None:
self.set_path(log_dir)
self._text_format_string = None
self._max_size = max_size
self._backup_count = backup_count

def reset(self):
if self.initialized:
Expand Down Expand Up @@ -384,16 +388,16 @@ def set_path(self, log_dir):
self._log_path = log_path

def _super_init(self, log_path):
logbook.TimedRotatingFileHandler.__init__(
logbook.RotatingFileHandler.__init__(
self,
filename=log_path,
level=self.level,
filter=self.filter,
delay=True,
max_size=self._max_size,
backup_count=self._backup_count,
bubble=self.bubble,
format_string=DEBUG_LOG_FORMAT,
date_format='%Y-%m-%d',
backup_count=7,
timed_filename_for_current=False,
)
FormatterMixin.__init__(self, DEBUG_LOG_FORMAT)

Expand Down

0 comments on commit 76dc41b

Please sign in to comment.