use stdout for logging.INFO and lower; for the rest use stderr
This commit is contained in:
parent
dffe82653c
commit
b0157137e2
@ -30,12 +30,13 @@ Features
|
||||
Bug fixes
|
||||
*****************
|
||||
|
||||
- `server_defaults` passed to :meth:`Column.create <migrate.changeset.schema.ChangesetColumn.create>` are now issued correctly
|
||||
- `server_defaults` passed to :meth:`Column.create <migrate.changeset.schema.ChangesetColumn.create>`
|
||||
are now issued correctly
|
||||
- use SQLAlchemy quoting system to avoid name conflicts (for issue 32)
|
||||
- complete refactoring of :class:`~migrate.changeset.schema.ColumnDelta` (fixes issue 23)
|
||||
- partial refactoring of :mod:`changeset` package
|
||||
- fixed bug when :meth:`Column.alter <migrate.changeset.schema.ChangesetColumn.alter>`\(server_default='string') was not properly set
|
||||
- constraints passed to :meth:`Column.create <migrate.changeset.schema.ChangesetColumn.create>` are correctly interpreted (``ALTER TABLE ADD CONSTRAINT`` is issued after ``ATLER TABLE ADD COLUMN``)
|
||||
- constraints passed to :meth:`Column.create <migrate.changeset.schema.ChangesetColumn.create>` are correctly interpreted (``ALTER TABLE ADD CONSTRAINT`` is issued after ``ATLER TABLE ADD COLUMN``)
|
||||
|
||||
Documentation
|
||||
*********************
|
||||
|
@ -161,12 +161,29 @@ def main(argv=None, **kwargs):
|
||||
|
||||
# configure logging
|
||||
if not asbool(kwargs.pop('disable_logging', False)):
|
||||
# filter to log =< INFO into stdout and rest to stderr
|
||||
class SingleLevelFilter(logging.Filter):
|
||||
def __init__(self, min=None, max=None):
|
||||
self.min = min or 0
|
||||
self.max = max or 100
|
||||
|
||||
def filter(self, record):
|
||||
return self.min <= record.levelno <= self.max
|
||||
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.INFO)
|
||||
formatter = logging.Formatter("%(message)s")
|
||||
ch = logging.StreamHandler(sys.stdout)
|
||||
ch.setFormatter(formatter)
|
||||
logger.addHandler(ch)
|
||||
h1 = logging.StreamHandler(sys.stdout)
|
||||
f1 = SingleLevelFilter(max=logging.INFO)
|
||||
h1.addFilter(f1)
|
||||
h2 = logging.StreamHandler(sys.stderr)
|
||||
f2 = SingleLevelFilter(min=logging.WARN)
|
||||
h2.addFilter(f2)
|
||||
logger.addHandler(h1)
|
||||
logger.addHandler(h2)
|
||||
|
||||
if options.debug:
|
||||
logger.setLevel(logging.DEBUG)
|
||||
else:
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user