| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <string>
 | 
					
						
							|  |  |  | #include <chrono>
 | 
					
						
							|  |  |  | #include <memory>
 | 
					
						
							|  |  |  | #include <vector>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 04:29:52 +03:00
										 |  |  | #include "../formatter.h"
 | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | #include "./log_msg.h"
 | 
					
						
							|  |  |  | #include "./fast_oss.h"
 | 
					
						
							|  |  |  | #include "./os.h"
 | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace c11log | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | namespace details { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  | class flag_formatter | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     virtual void format(details::log_msg& msg) = 0; | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // log name appender
 | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  | class name_formatter :public flag_formatter | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     void format(details::log_msg& msg) override | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         msg.formatted << msg.logger_name; | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // log level appender
 | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  | class level_formatter :public flag_formatter | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     void format(details::log_msg& msg) override | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         msg.formatted << level::to_str(msg.level); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Date time pattern appenders
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | static const char* ampm(const tm& t) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return t.tm_hour >= 12 ? "PM" : "AM"; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int to12h(const tm& t) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return t.tm_hour > 12 ? t.tm_hour - 12 : t.tm_hour; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //Abbreviated weekday name
 | 
					
						
							|  |  |  | static const std::string days[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; | 
					
						
							|  |  |  | class a_formatter :public flag_formatter | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     void format(details::log_msg& msg) override | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_str(days[msg.tm_time.tm_wday]); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //Full weekday name
 | 
					
						
							|  |  |  | static const std::string full_days[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; | 
					
						
							|  |  |  | class A_formatter :public flag_formatter | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     void format(details::log_msg& msg) override | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_str(full_days[msg.tm_time.tm_wday]); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //Abbreviated month
 | 
					
						
							|  |  |  | static const std::string  months[] { "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec" }; | 
					
						
							|  |  |  | class b_formatter :public flag_formatter | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     void format(details::log_msg& msg) override | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_str(months[msg.tm_time.tm_mon]); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //Full month name
 | 
					
						
							|  |  |  | static const std::string full_months[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; | 
					
						
							|  |  |  | class B_formatter :public flag_formatter | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     void format(details::log_msg& msg) override | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_str(full_months[msg.tm_time.tm_mon]); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //Date and time representation (Thu Aug 23 15:35:46 2014)
 | 
					
						
							|  |  |  | class c_formatter :public flag_formatter | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     void format(details::log_msg& msg) override | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_str(days[msg.tm_time.tm_wday]); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         msg.formatted.putc(' '); | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_str(months[msg.tm_time.tm_mon]); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         msg.formatted.putc(' '); | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_mday, 2); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         msg.formatted.putc(' '); | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_hour, 2); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         msg.formatted.putc(':'); | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_min, 2); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         msg.formatted.putc(':'); | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_sec, 2); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | // year - 2 digit
 | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | class C_formatter :public flag_formatter | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     void format(details::log_msg& msg) override | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_year % 100, 2); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Short MM/DD/YY date, equivalent to %m/%d/%y 08/23/01
 | 
					
						
							|  |  |  | class D_formatter :public flag_formatter | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     void format(details::log_msg& msg) override | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_mon + 1, 2); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         msg.formatted.putc('/'); | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_mday, 2); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         msg.formatted.putc('/'); | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_year % 100, 2); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // year - 4 digit
 | 
					
						
							|  |  |  | class Y_formatter :public flag_formatter | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     void format(details::log_msg& msg) override | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_year + 1900, 4); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | // month 1-12
 | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  | class m_formatter :public flag_formatter | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     void format(details::log_msg& msg) override | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_mon + 1, 2); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // day of month 1-31
 | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  | class d_formatter :public flag_formatter | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     void format(details::log_msg& msg) override | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_mday, 2); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // hours in 24 format  0-23
 | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  | class H_formatter :public flag_formatter | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     void format(details::log_msg& msg) override | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_hour, 2); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // hours in 12 format  1-12
 | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  | class I_formatter :public flag_formatter | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     void format(details::log_msg& msg) override | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(to12h(msg.tm_time), 2); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // ninutes 0-59
 | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  | class M_formatter :public flag_formatter | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     void format(details::log_msg& msg) override | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_min, 2); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // seconds 0-59
 | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  | class S_formatter :public flag_formatter | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     void format(details::log_msg& msg) override | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_sec, 2); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // milliseconds
 | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  | class e_formatter :public flag_formatter | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     void format(details::log_msg& msg) override | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     { | 
					
						
							|  |  |  |         auto duration = msg.time.time_since_epoch(); | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count() % 1000; | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(static_cast<int>(millis), 3); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | // AM/PM
 | 
					
						
							|  |  |  | class p_formatter :public flag_formatter | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     void format(details::log_msg& msg) override | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_data(ampm(msg.tm_time), 2); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // 12 hour clock 02:55:02 pm
 | 
					
						
							|  |  |  | class r_formatter :public flag_formatter | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     void format(details::log_msg& msg) override | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int hours = to12h(msg.tm_time); | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(to12h(msg.tm_time), 2); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         msg.formatted.putc(':'); | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_min, 2); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         msg.formatted.putc(':'); | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_sec, 2); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         msg.formatted.putc(' '); | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_data(ampm(msg.tm_time), 2); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // 24-hour HH:MM time, equivalent to %H:%M
 | 
					
						
							|  |  |  | class R_formatter :public flag_formatter | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     void format(details::log_msg& msg) override | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_hour, 2); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         msg.formatted.putc(':'); | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_min, 2); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // ISO 8601 time format (HH:MM:SS), equivalent to %H:%M:%S
 | 
					
						
							|  |  |  | class T_formatter :public flag_formatter | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     void format(details::log_msg& msg) override | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_hour, 2); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         msg.formatted.putc(':'); | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_min, 2); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         msg.formatted.putc(':'); | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_int(msg.tm_time.tm_sec, 2); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  | // ISO 8601 offset from UTC in timezone (HH:MM)
 | 
					
						
							|  |  |  | class z_formatter :public flag_formatter | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void format(log_msg& msg) override | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         std::lock_guard<std::mutex> l(_mutex); | 
					
						
							|  |  |  |         using namespace std::chrono; | 
					
						
							|  |  |  |         auto diff = msg.time - _last_update; | 
					
						
							|  |  |  |         auto secs_diff = abs((duration_cast<seconds>(diff)).count()); | 
					
						
							|  |  |  |         if (secs_diff >= 2) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             _value = get_value(msg); | 
					
						
							|  |  |  |             _last_update = msg.time; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         msg.formatted.put_str(_value); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     log_clock::time_point _last_update; | 
					
						
							|  |  |  |     std::string _value; | 
					
						
							|  |  |  |     std::string get_value(const log_msg& msg) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int total_minutes = os::utc_minutes_offset(msg.tm_time); | 
					
						
							|  |  |  |         int h = total_minutes / 60; | 
					
						
							|  |  |  |         int m = total_minutes % 60; | 
					
						
							|  |  |  |         fast_oss oss; | 
					
						
							|  |  |  |         oss.putc(h < 0 ? '-' : '+'); | 
					
						
							|  |  |  |         oss.put_int(h, 2); | 
					
						
							|  |  |  |         oss.putc(':'); | 
					
						
							|  |  |  |         oss.put_int(m, 2); | 
					
						
							|  |  |  |         return oss.str(); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |     std::mutex _mutex; | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  | class t_formatter :public flag_formatter | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     void format(details::log_msg& msg) override | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_fast_oss(msg.raw); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  | class ch_formatter :public flag_formatter | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     explicit ch_formatter(char ch) : _ch(ch) | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     {} | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     void format(details::log_msg& msg) override | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         msg.formatted.putc(_ch); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     char _ch; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | //aggregate user chars to display as is
 | 
					
						
							|  |  |  | class aggregate_formatter :public flag_formatter | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |     aggregate_formatter() | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     {} | 
					
						
							|  |  |  |     void add_ch(char ch) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         _str += ch; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     void format(details::log_msg& msg) override | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |         msg.formatted.put_str(_str); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     std::string _str; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2014-10-14 04:29:52 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class pattern_formatter : public formatter | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     explicit pattern_formatter(const std::string& pattern); | 
					
						
							|  |  |  |     pattern_formatter(const pattern_formatter&) = delete; | 
					
						
							|  |  |  |     void format(details::log_msg& msg) override; | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     const std::string _pattern; | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     std::vector<std::unique_ptr<details::flag_formatter>> _formatters; | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     void handle_flag(char flag); | 
					
						
							|  |  |  |     void compile_pattern(const std::string& pattern); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2014-10-14 04:29:52 +03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // pattern_formatter inline impl
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2014-10-14 04:29:52 +03:00
										 |  |  | inline c11log::details::pattern_formatter::pattern_formatter(const std::string& pattern) | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							|  |  |  |     compile_pattern(pattern); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 04:29:52 +03:00
										 |  |  | inline void c11log::details::pattern_formatter::compile_pattern(const std::string& pattern) | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							|  |  |  |     auto end = pattern.end(); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |     std::unique_ptr<aggregate_formatter> user_chars; | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     for (auto it = pattern.begin(); it != end; ++it) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (*it == '%') | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |             if (user_chars) //append user chars found so far
 | 
					
						
							|  |  |  |                 _formatters.push_back(std::move(user_chars)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |             if (++it != end) | 
					
						
							|  |  |  |                 handle_flag(*it); | 
					
						
							|  |  |  |             else | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         else // chars not following the % sign should be displayed as is
 | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |             if (!user_chars) | 
					
						
							|  |  |  |                 user_chars = std::unique_ptr<aggregate_formatter>(new aggregate_formatter()); | 
					
						
							|  |  |  |             user_chars->add_ch(*it); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |     if (user_chars) //append raw chars found so far
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         _formatters.push_back(std::move(user_chars)); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2014-10-14 04:29:52 +03:00
										 |  |  | inline void c11log::details::pattern_formatter::handle_flag(char flag) | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							|  |  |  |     switch (flag) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     // logger name
 | 
					
						
							|  |  |  |     case 'n': | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::name_formatter())); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     case 'l': | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::level_formatter())); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     case('t') : | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::t_formatter())); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     case('a') : | 
					
						
							|  |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::a_formatter())); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case('A') : | 
					
						
							|  |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::A_formatter())); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |     case('b') : | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |     case('h') : | 
					
						
							|  |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::b_formatter())); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case('B') : | 
					
						
							|  |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::B_formatter())); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case('c') : | 
					
						
							|  |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::c_formatter())); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case('C') : | 
					
						
							|  |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::C_formatter())); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     case('Y') : | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::Y_formatter())); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     case('D') : | 
					
						
							|  |  |  |     case('x') : | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::D_formatter())); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     case('m') : | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::m_formatter())); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     case('d') : | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::d_formatter())); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     case('H') : | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::H_formatter())); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     case('I') : | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::I_formatter())); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     case('M') : | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::M_formatter())); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     case('S') : | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::S_formatter())); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |     case('e') : | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::e_formatter())); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |     case('p') : | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::p_formatter())); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case('r') : | 
					
						
							|  |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::r_formatter())); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case('R') : | 
					
						
							|  |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::R_formatter())); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case('T') : | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |     case('X') : | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::T_formatter())); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-19 17:44:57 +03:00
										 |  |  |     case('z') : | 
					
						
							|  |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::z_formatter())); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |     default: //Unkown flag appears as is
 | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::ch_formatter('%'))); | 
					
						
							| 
									
										
										
										
											2014-10-19 02:54:45 +03:00
										 |  |  |         _formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::ch_formatter(flag))); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-14 04:29:52 +03:00
										 |  |  | inline void c11log::details::pattern_formatter::format(details::log_msg& msg) | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     for (auto &f : _formatters) | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |         f->format(msg); | 
					
						
							| 
									
										
										
										
											2014-10-14 03:44:40 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-10-15 00:46:14 +03:00
										 |  |  |     //write eol
 | 
					
						
							|  |  |  |     msg.formatted.write(details::os::eol(), details::os::eol_size()); | 
					
						
							| 
									
										
										
										
											2014-10-14 04:56:10 +03:00
										 |  |  | } |