Skip to main content

passing/
passing.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;
23use std::rc::Rc;
24
25use astrolog::handler::console::ConsoleHandler;
26use astrolog::prelude::*;
27
28fn main() {
29	let logger = Logger::new()
30		.with_global("OS", env::consts::OS)
31		.with_handler(ConsoleHandler::new().with_levels_range(Level::Info, Level::Emergency))
32		.into_rc();
33
34	get_by_ref(&logger);
35	get_by_rc(logger.clone());
36}
37
38fn get_by_ref(logger: &Logger) {
39	logger.info("Passed by reference")
40}
41
42fn get_by_rc(logger: Rc<Logger>) {
43	logger.info("Passed by Rc")
44}