projects
/
sawsim.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
19ff30c
)
Add the PYSAWSIM_LOG_LEVEL environmental variable.
author
W. Trevor King
<wking@drexel.edu>
Fri, 16 Sep 2011 16:30:32 +0000
(12:30 -0400)
committer
W. Trevor King
<wking@drexel.edu>
Fri, 16 Sep 2011 16:30:32 +0000
(12:30 -0400)
pysawsim/__init__.py
patch
|
blob
|
history
pysawsim/parameter_error.py
patch
|
blob
|
history
pysawsim/parameter_scan.py
patch
|
blob
|
history
pysawsim/sawsim.py
patch
|
blob
|
history
pysawsim/sawsim_histogram.py
patch
|
blob
|
history
diff --git
a/pysawsim/__init__.py
b/pysawsim/__init__.py
index 9cb3a97a5311b8ccc2f6dc31c730c27e4c0e6f39..19cfcba86e65b2e71da07ac3525fa11f1b491f33 100644
(file)
--- a/
pysawsim/__init__.py
+++ b/
pysawsim/__init__.py
@@
-47,7
+47,8
@@
Just go crazy with doctests and unittests; nose_ will find them.
import logging
import logging.handlers
import logging
import logging.handlers
-import sys
+import sys as _sys
+import os as _os
_multiprocess_shared_ = True
_multiprocess_shared_ = True
@@
-59,10
+60,24
@@
This module cannot be split because _log setup is not re-entrant.
__version__ = '0.10' # match sawsim version
__version__ = '0.10' # match sawsim version
+PYSAWSIM_LOG_LEVEL_MSG = """
+You can control the log verbosity with the `PYSAWSIM_LOG_LEVEL`
+environmental variable. Set it to one of the level names in Python's
+`logging` module (e.g. `DEBUG`).
+"""
+
def log():
return logging.getLogger('pysawsim')
def log():
return logging.getLogger('pysawsim')
-def add_stderr_log_handler(level=logging.DEBUG):
+def add_stderr_log_handler(level=None):
+ if level == None:
+ level_string = _os.environ.get('PYSAWSIM_LOG_LEVEL', 'WARNING')
+ try:
+ level = getattr(logging, level_string)
+ except AttributeError:
+ _sys.stderr.write(
+ 'unrecognized PYSAWSIM_LOG_LEVEL: %s\n' % level_string)
+ raise
_log = log()
_log.setLevel(level)
console = logging.StreamHandler()
_log = log()
_log.setLevel(level)
console = logging.StreamHandler()
@@
-70,4
+85,4
@@
def add_stderr_log_handler(level=logging.DEBUG):
console.setFormatter(formatter)
_log.addHandler(console)
console.setFormatter(formatter)
_log.addHandler(console)
-add_stderr_log_handler(
logging.WARNING
)
+add_stderr_log_handler()
diff --git
a/pysawsim/parameter_error.py
b/pysawsim/parameter_error.py
index f56ba26da72511d93cd49590fa39177c22dd80f9..44031f249f535f8f97039e0d6e59bbf206518d7e 100644
(file)
--- a/
pysawsim/parameter_error.py
+++ b/
pysawsim/parameter_error.py
@@
-22,6
+22,7
@@
import numpy
import numpy
+from . import PYSAWSIM_LOG_LEVEL_MSG as _PYSAWSIM_LOG_LEVEL_MSG
from .histogram import Histogram
from .parameter_scan import (
EXAMPLE_HISTOGRAM_FILE_CONTENTS, HistogramMatcher,
from .histogram import Histogram
from .parameter_scan import (
EXAMPLE_HISTOGRAM_FILE_CONTENTS, HistogramMatcher,
@@
-122,6
+123,7
@@
def main(argv=None):
'`<bin_edge>` should mark the left-hand side of the bin, and',
'all bins should be of equal width (so we know where the last',
'one ends).',
'`<bin_edge>` should mark the left-hand side of the bin, and',
'all bins should be of equal width (so we know where the last',
'one ends).',
+ _PYSAWSIM_LOG_LEVEL_MSG,
])
parser = OptionParser(usage, epilog=epilog)
parser.format_epilog = lambda formatter: epilog+'\n'
])
parser = OptionParser(usage, epilog=epilog)
parser.format_epilog = lambda formatter: epilog+'\n'
diff --git
a/pysawsim/parameter_scan.py
b/pysawsim/parameter_scan.py
index 439fd0b1bbfbdb6ee2dda74190c6611fb522ebe9..0f30fb634024166ae52d1f588f5126f63e173d3f 100644
(file)
--- a/
pysawsim/parameter_scan.py
+++ b/
pysawsim/parameter_scan.py
@@
-31,6
+31,7
@@
import numpy
import pylab
from . import log
import pylab
from . import log
+from . import PYSAWSIM_LOG_LEVEL_MSG as _PYSAWSIM_LOG_LEVEL_MSG
from .histogram import Histogram
from .sawsim_histogram import sawsim_histogram
from .sawsim import SawsimRunner
from .histogram import Histogram
from .sawsim_histogram import sawsim_histogram
from .sawsim import SawsimRunner
@@
-381,6
+382,7
@@
def main(argv=None):
'`<bin_edge>` should mark the left-hand side of the bin, and',
'all bins should be of equal width (so we know where the last',
'one ends).',
'`<bin_edge>` should mark the left-hand side of the bin, and',
'all bins should be of equal width (so we know where the last',
'one ends).',
+ PYSAWSIM_LOG_LEVEL_MSG,
])
parser = OptionParser(usage, epilog=epilog)
parser.format_epilog = lambda formatter: epilog+'\n'
])
parser = OptionParser(usage, epilog=epilog)
parser.format_epilog = lambda formatter: epilog+'\n'
diff --git
a/pysawsim/sawsim.py
b/pysawsim/sawsim.py
index 0f85869dd634111a0ce0f64d65a9700895f6d8f1..da726c749143bc59382c146c0d54c66a3b9275e6 100644
(file)
--- a/
pysawsim/sawsim.py
+++ b/
pysawsim/sawsim.py
@@
-37,6
+37,7
@@
import shutil
from uuid import uuid4
from . import __version__
from uuid import uuid4
from . import __version__
+from . import PYSAWSIM_LOG_LEVEL_MSG as _PYSAWSIM_LOG_LEVEL_MSG
from .manager import MANAGERS, get_manager, InvokeJob
from .manager import MANAGERS, get_manager, InvokeJob
@@
-302,9
+303,11
@@
def main(argv=None):
epilog = '\n'.join([
'Python wrapper around `sawsim`. Distribute `N` runs using',
'one of the possible job "managers". Also supports caching',
epilog = '\n'.join([
'Python wrapper around `sawsim`. Distribute `N` runs using',
'one of the possible job "managers". Also supports caching',
- 'results to speed future runs.'
+ 'results to speed future runs.',
+ _PYSAWSIM_LOG_LEVEL_MSG,
])
parser = OptionParser(usage, epilog=epilog)
])
parser = OptionParser(usage, epilog=epilog)
+ parser.format_epilog = lambda formatter: epilog+'\n'
for option in sr.optparse_options:
parser.add_option(option)
for option in sr.optparse_options:
parser.add_option(option)
diff --git
a/pysawsim/sawsim_histogram.py
b/pysawsim/sawsim_histogram.py
index 14b94ede18227195f61fa294a835d1d116f1b288..d349316a8cd974d69ac8f3275ba34379738ada82 100644
(file)
--- a/
pysawsim/sawsim_histogram.py
+++ b/
pysawsim/sawsim_histogram.py
@@
-19,6
+19,7
@@
import numpy
import numpy
+from . import PYSAWSIM_LOG_LEVEL_MSG as _PYSAWSIM_LOG_LEVEL_MSG
from .histogram import Histogram
from .manager import MANAGERS, get_manager
from .sawsim import SawsimRunner
from .histogram import Histogram
from .manager import MANAGERS, get_manager
from .sawsim import SawsimRunner
@@
-67,8
+68,10
@@
def main(argv=None):
epilog = '\n'.join([
'Generate an unfolding force histogram from a series of `sawsim`',
'runs.',
epilog = '\n'.join([
'Generate an unfolding force histogram from a series of `sawsim`',
'runs.',
- ])
+ _PYSAWSIM_LOG_LEVEL_MSG,
+ ])
parser = OptionParser(usage, epilog=epilog)
parser = OptionParser(usage, epilog=epilog)
+ parser.format_epilog = lambda formatter: epilog+'\n'
for option in sr.optparse_options:
parser.add_option(option)
parser.add_option('-w', '--bin-width', dest='bin_width',
for option in sr.optparse_options:
parser.add_option(option)
parser.add_option('-w', '--bin-width', dest='bin_width',