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

Remove support for the 'fileline' attribute in log formats #678

Merged
merged 3 commits into from
Oct 6, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 1 addition & 2 deletions conf_files/log.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ logger:
datefmt: '%H:%M:%S'
detail:
style: '{'
# See FilenameLineFilter in logger.py for fileline description
format: '{levelname:.1s}{asctime}.{msecs:03.0f} {fileline:20s} {message}'
format: '{levelname:.1s}{asctime}.{msecs:03.0f} {filename} {lineno} {message}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer we still have a fixed length for filename and lineno so the the message always start with a left flush. I could live without but I think it makes reading easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

datefmt: '%m%d %H:%M:%S'
handlers:
all:
Expand Down
12 changes: 0 additions & 12 deletions pocs/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ def get_root_logger(profile='panoptes', log_config=None):
# Set custom LogRecord
logging.setLogRecordFactory(StrFormatLogRecord)

# Add a filter for better filename/lineno
logger.addFilter(FilenameLineFilter())

logger.info('{:*^80}'.format(' Starting PanLogger '))
# TODO(jamessynge) Output name of script, cmdline args, etc. And do son
# when the log rotates too!
Expand All @@ -141,12 +138,3 @@ class _UTCFormatter(logging.Formatter):

""" Simple class to convert times to UTC in the logger """
converter = time.gmtime


class FilenameLineFilter(logging.Filter):
"""Adds a simple concatenation of filename and lineno for fixed length """

def filter(self, record):

record.fileline = '{}:{}'.format(record.filename, record.lineno)
return True
2 changes: 1 addition & 1 deletion scripts/run_social_messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def run_social_sinks(msg_port, social_twitter, social_slack):
# This is early in startup to ensure the PANOPTES logging code is
# installed early. Unfortunately this doesn't (yet) prevent the
# problem with our format keyword 'fileline' causing problems for
# other loggers.
# other loggers. See issue #393.
pocs_config = load_config()
the_root_logger = get_root_logger()

Expand Down