Skip to content

Commit

Permalink
Testing behavior of logging on py 2.6
Browse files Browse the repository at this point in the history
Expect to kill this commit, want to run it on Travis though
  • Loading branch information
sirosen committed Oct 21, 2015
1 parent 88d7c6e commit e514184
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
16 changes: 7 additions & 9 deletions salve/log/basic_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ def setup_stderr(logger):


def str_to_level(lvlstr):
mapping = {
'DEBUG': logging.DEBUG,
'INFO': logging.INFO,
'WARNING': logging.WARNING,
'ERROR': logging.ERROR
}
if lvlstr in mapping:
return mapping[lvlstr]
else:
try:
return dict(
(logging.getLevelName(l), l) for l in
[logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR,
logging.CRITICAL]
)[lvlstr.upper()]
except KeyError:
raise ValueError('{0} is not a valid log level'.format(lvlstr))
2 changes: 1 addition & 1 deletion salve/log/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def gen_handler(filename=None, stream=None):
# case where it's unspecified, omit it so that StreamHandler
# defaults to sys.stderr
else:
hdlr = logging.StreamHandler()
hdlr = logging.StreamHandler(sys.stderr)
else:
# StreamHandler uses stderr if stream is None
hdlr = logging.StreamHandler(stream=stream)
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/action/backup_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ def dir_execute_no_source(self):
for subact in act.actions:
assert isinstance(subact, backup.FileBackupAction)


import logging
self.logger.addHandler(logging.StreamHandler(self.stderr))

act(ConcreteFilesys())

err = self.stderr.getvalue()
Expand Down

0 comments on commit e514184

Please sign in to comment.