global/global.rs
1/*
2Astrolog, a logging framework for Rust
3Copyright (C) 2019 Alessandro Pellizzari
4
5This library is free software; you can redistribute it and/or
6modify it under the terms of the GNU Lesser General Public
7License as published by the Free Software Foundation; either
8version 2.1 of the License, or (at your option) any later version.
9
10This library is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13Lesser General Public License for more details.
14
15You should have received a copy of the GNU Lesser General Public
16License along with this library; if not, write to the Free Software
17Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*/
19
20extern crate astrolog;
21
22use std::env;
23
24use astrolog::handler::console::ConsoleHandler;
25use astrolog::prelude::*;
26
27fn main() {
28 astrolog::config(|logger| {
29 logger
30 .set_global("OS", env::consts::OS)
31 .push_handler(ConsoleHandler::new().with_levels_range(Level::Info, Level::Emergency));
32 });
33
34 astrolog::debug("A debug message");
35 astrolog::info("A simple info logging");
36
37 astrolog::with("line", line!())
38 .with("file", file!())
39 .error("An error with some debug info");
40}