Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rotate the file at 10mb instead of by date #1871

Merged
merged 1 commit into from
Oct 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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