-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
got rid of an extra config file in favor of a dict config. made conso…
…le logging the default. fixed flake8 suggestions
- Loading branch information
Matthew Zizzi
committed
Sep 7, 2014
1 parent
6b25494
commit 775af7c
Showing
3 changed files
with
62 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
DEFAULT_CONFIG = { | ||
'version': 1, | ||
'formatters': { | ||
'generic': { | ||
'format': '%(asctime)s [%(levelname)-6s] [%(name)-s] %(message)s' | ||
} | ||
}, | ||
'handlers': { | ||
'console': { | ||
'class': 'logging.StreamHandler', | ||
'level': 'DEBUG', | ||
'formatter': 'generic' | ||
} | ||
}, | ||
'loggers': { | ||
'root': { | ||
'level': 'DEBUG', | ||
'handlers': [], | ||
'propagate': True | ||
}, | ||
'server': { | ||
'level': 'DEBUG', | ||
'handlers': ['console'] | ||
} | ||
} | ||
} | ||
|
||
|
||
def make_logging_config(aenea_config): | ||
log_file = getattr(aenea_config, 'LOG_FILE', None) | ||
console_level = getattr(aenea_config, 'CONSOLE_LOG_LEVEL', 'DEBUG') | ||
file_level = getattr(aenea_config, 'FILE_LOG_LEVEL', 'DEBUG') | ||
|
||
logging_config = DEFAULT_CONFIG.copy() | ||
logging_config['handlers']['console']['level'] = console_level | ||
|
||
if log_file is not None: | ||
logging_config['handlers']['file'] = { | ||
'class': 'logging.handlers.RotatingFileHandler', | ||
'formatter': 'generic', | ||
'level': file_level, | ||
'filename': log_file, | ||
'mode': 'a', | ||
'backupCount': 3 | ||
} | ||
logging_config['loggers']['server']['handlers'].append('file') | ||
|
||
return logging_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters