|
@@ 49-67 (lines=19) @@
|
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
def test_logging_file(basicApp, tmpdir): |
| 50 |
|
log_file = os.path.join(str(tmpdir), "test.log") |
| 51 |
|
app = basicApp |
| 52 |
|
# set up logging in the config, with log level INFO |
| 53 |
|
app.config.set('GROUNDWORK_LOGGING', _gw_logging_cfg(log_file)) |
| 54 |
|
app._configure_logging(app.config.get("GROUNDWORK_LOGGING")) |
| 55 |
|
|
| 56 |
|
debug_message = "This is a test debug message." |
| 57 |
|
info_message = "This is a test info message." |
| 58 |
|
app.log.debug(debug_message) |
| 59 |
|
app.log.info(info_message) |
| 60 |
|
|
| 61 |
|
# verify the contents of the log file |
| 62 |
|
with open(log_file) as lf: |
| 63 |
|
log = lf.read() |
| 64 |
|
# at log level INFO, the DEBUG message should not be there |
| 65 |
|
assert log.find(debug_message) == -1 |
| 66 |
|
# the INFO message should be there |
| 67 |
|
assert log.find(info_message) > 0 |
| 68 |
|
|
| 69 |
|
|
| 70 |
|
def test_logging_console(basicApp, tmpdir, capsys): |
|
@@ 70-86 (lines=17) @@
|
| 67 |
|
assert log.find(info_message) > 0 |
| 68 |
|
|
| 69 |
|
|
| 70 |
|
def test_logging_console(basicApp, tmpdir, capsys): |
| 71 |
|
log_file = os.path.join(str(tmpdir), "test.log") |
| 72 |
|
app = basicApp |
| 73 |
|
# set up logging in the config, with log level INFO |
| 74 |
|
app.config.set('GROUNDWORK_LOGGING', _gw_logging_cfg(log_file)) |
| 75 |
|
app._configure_logging(app.config.get("GROUNDWORK_LOGGING")) |
| 76 |
|
|
| 77 |
|
debug_message = "This is a test debug message." |
| 78 |
|
info_message = "This is a test info message." |
| 79 |
|
app.log.debug(debug_message) |
| 80 |
|
app.log.info(info_message) |
| 81 |
|
|
| 82 |
|
out, err = capsys.readouterr() |
| 83 |
|
# at log level INFO, the DEBUG message should not be there |
| 84 |
|
assert out.find(debug_message) == -1 |
| 85 |
|
# the INFO message should be there |
| 86 |
|
assert out.find(info_message) > 0 |
| 87 |
|
|