| 
									
										
										
										
											2014-03-22 14:11:17 +02:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include<string>
 | 
					
						
							| 
									
										
										
										
											2014-10-10 02:45:23 +03:00
										 |  |  | #include<mutex>
 | 
					
						
							| 
									
										
										
										
											2014-03-22 14:11:17 +02:00
										 |  |  | #include<atomic>
 | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | #include "./sink.h"
 | 
					
						
							| 
									
										
										
										
											2014-03-22 14:11:17 +02:00
										 |  |  | #include "../formatter.h"
 | 
					
						
							| 
									
										
										
										
											2014-10-10 03:36:50 +03:00
										 |  |  | #include "../common.h"
 | 
					
						
							| 
									
										
										
										
											2014-03-28 19:03:24 +03:00
										 |  |  | #include "../details/log_msg.h"
 | 
					
						
							| 
									
										
										
										
											2014-03-22 14:11:17 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-10 02:45:23 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-22 14:11:17 +02:00
										 |  |  | namespace c11log | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | namespace sinks | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-10-10 02:45:23 +03:00
										 |  |  | template<class Mutex> | 
					
						
							| 
									
										
										
										
											2014-10-14 04:26:51 +03:00
										 |  |  | class base_sink:public sink | 
					
						
							| 
									
										
										
										
											2014-03-22 14:11:17 +02:00
										 |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2014-10-10 21:17:26 +03:00
										 |  |  |     base_sink():_mutex() {} | 
					
						
							| 
									
										
										
										
											2014-03-22 14:11:17 +02:00
										 |  |  |     virtual ~base_sink() = default; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     base_sink(const base_sink&) = delete; | 
					
						
							|  |  |  |     base_sink& operator=(const base_sink&) = delete; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-10 03:36:50 +03:00
										 |  |  |     void log(const details::log_msg& msg) override | 
					
						
							| 
									
										
										
										
											2014-03-22 14:11:17 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-10 21:17:26 +03:00
										 |  |  |         std::lock_guard<Mutex> lock(_mutex); | 
					
						
							|  |  |  |         _sink_it(msg); | 
					
						
							| 
									
										
										
										
											2014-03-22 14:11:17 +02:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							| 
									
										
										
										
											2014-03-28 19:03:24 +03:00
										 |  |  |     virtual void _sink_it(const details::log_msg& msg) = 0; | 
					
						
							| 
									
										
										
										
											2014-10-10 02:45:23 +03:00
										 |  |  |     Mutex _mutex; | 
					
						
							| 
									
										
										
										
											2014-03-22 14:11:17 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | } |