forked from market-microstructure/simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v. 0.1.1 - Added logging functionality
- Loading branch information
Silviu VLASCEANU
committed
Oct 7, 2013
1 parent
ff37153
commit 3dfeb37
Showing
13 changed files
with
59 additions
and
12 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
Binary file not shown.
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
Binary file not shown.
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
Binary file not shown.
File renamed without changes.
Binary file not shown.
Empty file.
Binary file not shown.
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,47 @@ | ||
''' | ||
Created on Oct 7, 2013 | ||
@author: Silver | ||
''' | ||
|
||
import logging, sys | ||
|
||
|
||
class LowerLevelFilter(logging.Filter): | ||
def __init__(self, passlevel, reject): | ||
self.passlevel = passlevel | ||
self.reject = reject | ||
|
||
def filter(self, record): | ||
""" | ||
this filter helps push messages below a certain level to stdout while leaving the rest to stderr | ||
""" | ||
if self.reject: | ||
return (record.levelno > self.passlevel) | ||
else: | ||
return (record.levelno <= self.passlevel) | ||
|
||
def get_logger(): | ||
# create logger | ||
#logging.basicConfig(format = '%(asctime)s %(levelname)s %(module)s:%(lineno)d >> %(message)s') | ||
formatter = logging.Formatter('%(asctime)s\t%(levelname)s\t%(module)s:%(lineno)d\t%(message)s') | ||
root_logger = logging.getLogger() | ||
root_logger.setLevel(logging.DEBUG) | ||
root_logger.handlers = [] | ||
|
||
j = logging.StreamHandler(sys.stderr) | ||
j.setLevel(logging.DEBUG) | ||
j.addFilter(LowerLevelFilter(logging.INFO, True)) | ||
j.setFormatter(formatter) | ||
|
||
h = logging.StreamHandler(sys.stdout) | ||
h.setLevel(logging.DEBUG) | ||
h.addFilter(LowerLevelFilter(logging.INFO, False)) | ||
h.setFormatter(formatter) | ||
|
||
root_logger.addHandler(h) | ||
root_logger.addHandler(j) | ||
|
||
return root_logger | ||
|
||
|
Binary file not shown.