-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from appsembler/john/update-monthly-task
John/update monthly task
- Loading branch information
Showing
14 changed files
with
239 additions
and
51 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
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,38 @@ | ||
"""Provides logging and instrumentation functionality for Figures | ||
""" | ||
|
||
from contextlib import contextmanager | ||
import logging | ||
import timeit | ||
|
||
|
||
default_logger = logging.getLogger(__name__) | ||
|
||
|
||
@contextmanager | ||
def log_exec_time(description, logger=None): | ||
"""Context handler to log execution time info for a block | ||
Parameters: | ||
description : The text to add to the log statement | ||
logger : The logger to receive the log statement | ||
If `logger' is not provided, then the default logger is used, | ||
`logging.getLogger(__name__)` | ||
Example: | ||
``` | ||
with log_exec_time('Collect grades for courses in site',logger=my_logger): | ||
do_grades_collection(site=my_site) | ||
``` | ||
""" | ||
logger = logger if logger else default_logger | ||
start_time = timeit.default_timer() | ||
yield | ||
elapsed = timeit.default_timer() - start_time | ||
msg = '{}: {} s'.format(description, elapsed) | ||
|
||
logger.info(msg) |
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
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
Oops, something went wrong.