mirror of https://github.com/gabime/spdlog.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
870 B
C
44 lines
870 B
C
![]()
12 years ago
|
#pragma once
|
||
![]()
11 years ago
|
//
|
||
|
// base sink templated over a mutex (either dummy or realy)
|
||
|
// concrete implementation should only overrid the _sink_it method.
|
||
|
// all locking is taken care of here so no locking needed by the implementors..
|
||
|
//
|
||
![]()
12 years ago
|
|
||
|
#include<string>
|
||
![]()
11 years ago
|
#include<mutex>
|
||
![]()
12 years ago
|
#include<atomic>
|
||
![]()
11 years ago
|
#include "./sink.h"
|
||
![]()
12 years ago
|
#include "../formatter.h"
|
||
![]()
11 years ago
|
#include "../common.h"
|
||
![]()
12 years ago
|
#include "../details/log_msg.h"
|
||
![]()
12 years ago
|
|
||
![]()
11 years ago
|
|
||
![]()
11 years ago
|
namespace spitlog
|
||
![]()
12 years ago
|
{
|
||
|
namespace sinks
|
||
|
{
|
||
![]()
11 years ago
|
template<class Mutex>
|
||
![]()
11 years ago
|
class base_sink:public sink
|
||
![]()
12 years ago
|
{
|
||
|
public:
|
||
![]()
11 years ago
|
base_sink():_mutex() {}
|
||
![]()
12 years ago
|
virtual ~base_sink() = default;
|
||
|
|
||
|
base_sink(const base_sink&) = delete;
|
||
|
base_sink& operator=(const base_sink&) = delete;
|
||
|
|
||
![]()
11 years ago
|
void log(const details::log_msg& msg) override
|
||
![]()
12 years ago
|
{
|
||
![]()
11 years ago
|
std::lock_guard<Mutex> lock(_mutex);
|
||
|
_sink_it(msg);
|
||
![]()
12 years ago
|
};
|
||
|
|
||
|
|
||
|
protected:
|
||
![]()
12 years ago
|
virtual void _sink_it(const details::log_msg& msg) = 0;
|
||
![]()
11 years ago
|
Mutex _mutex;
|
||
![]()
12 years ago
|
};
|
||
|
}
|
||
|
}
|