Skip to content

Commit

Permalink
Set logger level on create (#121)
Browse files Browse the repository at this point in the history
Feature for get logger with custom name, level and format
  • Loading branch information
skyline-gleb authored Aug 8, 2017
1 parent 53b0207 commit 0abe574
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions contesto/utils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ def filter(self, record):
return True


def get_logger(name):
def get_logger(name, level=None, format_=LOG_FORMAT):
if not level:
level = getattr(logging, config.logging["level"].upper())

logger = logging.getLogger(name)
logger.setLevel(level)
context_filter = ContextFilter()

stream_handler = SessionStreamHandler()
log_level = getattr(logging, config.logging["level"].upper())
formatter = logging.Formatter(LOG_FORMAT)
stream_handler.setLevel(log_level)
formatter = logging.Formatter(format_)
stream_handler.setLevel(level)
stream_handler.setFormatter(formatter)

logger.addHandler(stream_handler)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'config/*.ini'
],
},
"version": "0.2.14",
"version": "0.3.0",
"install_requires": [
"selenium==2.52.0",
"Appium-Python-Client==0.24",
Expand Down

0 comments on commit 0abe574

Please sign in to comment.