David Brown | ca7b5d3 | 2017-11-03 08:37:38 -0600 | [diff] [blame] | 1 | //! Logging support for the test framework. |
| 2 | //! |
| 3 | //! https://stackoverflow.com/questions/30177845/how-to-initialize-the-logger-for-integration-tests |
| 4 | //! |
| 5 | //! The test framework runs the tests, possibly simultaneously, and in various orders. This helper |
| 6 | //! function, which should be called at the beginning of each test, will setup logging for all of |
| 7 | //! the tests. |
| 8 | |
| 9 | use env_logger; |
| 10 | use std::sync::{Once, ONCE_INIT}; |
| 11 | |
| 12 | static INIT: Once = ONCE_INIT; |
| 13 | |
| 14 | /// Setup the logging system. Intended to be called at the beginning of each test. |
| 15 | pub fn setup() { |
| 16 | INIT.call_once(|| { |
Fabio Utzig | 25d7b0f | 2019-01-10 11:01:04 -0200 | [diff] [blame^] | 17 | env_logger::init(); |
David Brown | ca7b5d3 | 2017-11-03 08:37:38 -0600 | [diff] [blame] | 18 | }); |
| 19 | } |