-
Notifications
You must be signed in to change notification settings - Fork 18
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
Use rotating log files #437
base: master
Are you sure you want to change the base?
Changes from 6 commits
fdb094f
edfe9f8
2f7d769
c26ea14
1ddb162
dc99a77
7e01d6d
0570fe2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
import logging | ||
from logging.handlers import RotatingFileHandler | ||
import os | ||
from abc import ABCMeta, abstractmethod | ||
|
||
log_dir = "logs" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we make this configurable somehow? |
||
if not os.path.exists(log_dir): | ||
os.makedirs(log_dir) | ||
|
||
logger = logging.getLogger('RAMP-WORKER') | ||
|
||
log_file = "worker.log" | ||
log_file = os.path.join(log_dir, "worker.log") | ||
formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s') # noqa | ||
fileHandler = logging.FileHandler(log_file, mode='a') | ||
fileHandler.setFormatter(formatter) | ||
streamHandler = logging.StreamHandler() | ||
streamHandler.setFormatter(formatter) | ||
file_handler = RotatingFileHandler(log_file, maxBytes=1000, backupCount=2) | ||
file_handler.setFormatter(formatter) | ||
stream_handler = logging.StreamHandler() | ||
stream_handler.setFormatter(formatter) | ||
|
||
logger.setLevel(logging.DEBUG) | ||
logger.addHandler(fileHandler) | ||
logger.addHandler(streamHandler) | ||
|
||
logger.addHandler(file_handler) | ||
logger.addHandler(stream_handler) | ||
|
||
class BaseWorker(metaclass=ABCMeta): | ||
"""Metaclass used to build a RAMP worker. Do not use this class directly. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
streamHandler -> stream_handler