c++ - Boost log not showing custom TimeStamp -
I am working with the Boost Log Library (version 1.55) and am trying to customize the output format. Unfortunately I can not seem to create a custom format to show the timestamp
attribute
Example program, which is derived from examples in the Boost log documentation:
#include & lt; Boost / log / trivial.hpp & gt; #include & lt; Boost / log / sinks.hpp & gt; # Include & lt; Boost / log / expressions.hpp & gt; #include & lt; Boost / log / support / date_time.hpp & gt; #include & lt; Boost / utility / empty_deleter.hpp & gt; Name locale logging = boost :: log; Namespace sync = Login :: Sync; Name space expr = logging :: expressions; Namespace = entrants = entry :: attributes; Int main () {text_sink = sinks :: synchronous_sink & lt; Sinks :: text_ostream_backend & gt; Auto Sync = Boost :: Make-Shed & lt; Text_sink & gt; (); // Add standard output to increase sync: shared_ptr & lt; Std :: ostream & gt; Stream (& amp; std :: cout, boost :: empty_deleter ()); Sink-> Locked_backend () - & gt; Add_stream (stream); // Set Output Appearance Sync- & gt; Set_former (XPro :: stream & lt; '<' & lt; expr :: format_date_time & lt; boost :: posix_time :: ptime & gt; ("timestamp", "% Y-% m -% d% H:% M:% S ") & lt;"] - "& lt;
Output from this program
[] - Hello World << pre>
Timestamp
, formatting works Part that should be within square brackets.Am I using the formatting work incorrectly or am I missing something else?
You & lt; Boost / log / utility / setup / common_attributes.hpp & gt;
and call function
should include logging:: Add_common_attributes ()
Comments
Post a Comment