-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update doc for css validation (#123)
* update doc for css validation * pep8 stype coding * minor change * pep8 coding update #2 * pep8 codin update #3 * pep8 codin update #4 * pep8 coding update #5
- Loading branch information
Showing
4 changed files
with
33 additions
and
26 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
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 |
---|---|---|
@@ -1,49 +1,51 @@ | ||
import logging | ||
import logging.handlers | ||
|
||
|
||
class LevelFilter(logging.Filter): | ||
"""Filters (lets through) all messages with level < LEVEL""" | ||
|
||
def __init__(self, level): | ||
self.level = level | ||
|
||
def filter(self, record): | ||
return record.levelno < self.level # "<" instead of "<=": since logger.setLevel is inclusive, this should be exclusive | ||
return record.levelno < self.level | ||
# "<" instead of "<=": since logger.setLevel is inclusive, this should be exclusive | ||
|
||
|
||
class Logger: | ||
|
||
@staticmethod | ||
def create_logger(debug_filename, err_filename, logger_name): | ||
logger = logging.getLogger(logger_name) | ||
logger.setLevel(logging.DEBUG) | ||
logger.propagate = False | ||
formatter = logging.Formatter( | ||
fmt='%(asctime)s %(levelname)s:%(name)s:%(funcName)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S') | ||
fmt='%(asctime)s %(levelname)s:%(name)s:%(funcName)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S') | ||
|
||
# ERROR log to 'snare.err' | ||
error_log_handler = logging.handlers.RotatingFileHandler(err_filename, encoding='utf-8') | ||
error_log_handler.setLevel(logging.ERROR) | ||
error_log_handler.setFormatter(formatter) | ||
logger.addHandler(error_log_handler) | ||
|
||
# DEBUG log to 'snare.log' | ||
debug_log_handler = logging.handlers.RotatingFileHandler(debug_filename, encoding='utf-8') | ||
debug_log_handler.setLevel(logging.DEBUG) | ||
debug_log_handler.setFormatter(formatter) | ||
max_level_filter = LevelFilter(logging.ERROR) | ||
debug_log_handler.addFilter(max_level_filter) | ||
logger.addHandler(debug_log_handler) | ||
|
||
return logger | ||
|
||
@staticmethod | ||
def create_clone_logger(err_filename, logger_name): | ||
logger = logging.getLogger(logger_name) | ||
formatter = logging.Formatter( | ||
fmt='%(asctime)s %(levelname)s:%(name)s:%(funcName)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S') | ||
fmt='%(asctime)s %(levelname)s:%(name)s:%(funcName)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S') | ||
# ERROR log to 'clone.err' | ||
error_log_handler = logging.handlers.RotatingFileHandler(err_filename, encoding='utf-8') | ||
error_log_handler.setLevel(logging.ERROR) | ||
error_log_handler.setFormatter(formatter) | ||
logger.addHandler(error_log_handler) | ||
|
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