Toggle navigation
MoMEMta
core
include
logger
base_sink.h
1
/*
2
* MoMEMta: a modular implementation of the Matrix Element Method
3
* Copyright (C) 2016 Universite catholique de Louvain (UCL), Belgium
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
// Heavily inspired by spdlog, Copyright(c) 2015 Gabi Melman
20
21
#pragma once
22
23
#include <momemta/impl/logger/sink.h>
24
25
#include <mutex>
26
27
namespace
logger
{
28
29
namespace
sinks {
30
31
template
<
class
Mutex>
32
class
base_sink
:
public
sink
{
33
public
:
34
base_sink
(): _mutex() {}
35
virtual
~
base_sink
() =
default
;
36
37
base_sink
(
const
base_sink
&) =
delete
;
38
base_sink
& operator=(
const
base_sink
&) =
delete
;
39
40
void
log(
const
details::log_msg
& msg)
override
{
41
std::lock_guard<Mutex> lock(_mutex);
42
_sink_it(msg);
43
}
44
45
protected
:
46
virtual
void
_sink_it(
const
details::log_msg
& msg) = 0;
47
Mutex _mutex;
48
};
49
50
}
51
52
}
logger::details::log_msg
Definition:
log_msg.h:34
logger::sinks::base_sink
Definition:
base_sink.h:32
logger::sinks::sink
Definition:
sink.h:30
logger
Definition:
base_sink.h:27
Generated by
1.8.13