blob: 77619e4ea7cb5494ed66ee246709b269e76c389f [file] [log] [blame]
David Browne2acfae2020-01-21 16:45:01 -07001// Copyright (c) 2017 Linaro LTD
2// Copyright (c) 2019 JUUL Labs
3//
4// SPDX-License-Identifier: Apache-2.0
5
David Brownca7b5d32017-11-03 08:37:38 -06006//! Logging support for the test framework.
7//!
8//! https://stackoverflow.com/questions/30177845/how-to-initialize-the-logger-for-integration-tests
9//!
10//! The test framework runs the tests, possibly simultaneously, and in various orders. This helper
11//! function, which should be called at the beginning of each test, will setup logging for all of
12//! the tests.
13
Fabio Utzigffc673e2019-10-30 09:22:04 -030014use std::sync::Once;
David Brownca7b5d32017-11-03 08:37:38 -060015
Fabio Utzigffc673e2019-10-30 09:22:04 -030016static INIT: Once = Once::new();
David Brownca7b5d32017-11-03 08:37:38 -060017
18/// Setup the logging system. Intended to be called at the beginning of each test.
19pub fn setup() {
20 INIT.call_once(|| {
Fabio Utzig25d7b0f2019-01-10 11:01:04 -020021 env_logger::init();
David Brownca7b5d32017-11-03 08:37:38 -060022 });
23}