1 /*
2  * Copyright (C) 2018 Codership Oy <info@codership.com>
3  *
4  * This file is part of wsrep-lib.
5  *
6  * Wsrep-lib is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * Wsrep-lib is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with wsrep-lib.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #include "wsrep/logger.hpp"
21 
22 #include <iostream>
23 
24 std::ostream& wsrep::log::os_ = std::cout;
25 static wsrep::default_mutex log_mutex_;
26 wsrep::mutex& wsrep::log::mutex_ = log_mutex_;
27 wsrep::log::logger_fn_type wsrep::log::logger_fn_ = 0;
28 std::atomic_int wsrep::log::debug_log_level_(0);
29 
logger_fn(wsrep::log::logger_fn_type logger_fn)30 void wsrep::log::logger_fn(wsrep::log::logger_fn_type logger_fn)
31 {
32     logger_fn_ = logger_fn;
33 }
34 
debug_log_level(int debug_log_level)35 void wsrep::log::debug_log_level(int debug_log_level)
36 {
37     debug_log_level_.store(debug_log_level, std::memory_order_relaxed);
38 }
39 
debug_log_level()40 int wsrep::log::debug_log_level()
41 {
42     return debug_log_level_.load(std::memory_order_relaxed);
43 }
44