Skip to main content

mwbot/
logging.rs

1/*
2Copyright (C) 2021 Kunal Mehta <legoktm@debian.org>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 3 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program.  If not, see <https://www.gnu.org/licenses/>.
16 */
17
18use tracing_subscriber::filter::LevelFilter;
19use tracing_subscriber::EnvFilter;
20
21/// Setup logging, can be adjusted by setting the `RUST_LOG` environment
22/// variable.
23pub fn init() {
24    let filter = EnvFilter::builder()
25        .with_default_directive(LevelFilter::INFO.into())
26        .from_env()
27        .expect("invalid RUST_LOG value");
28
29    tracing_subscriber::fmt().with_env_filter(filter).init();
30}