• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *          Copyright Andrey Semashev 2007 - 2015.
3  * Distributed under the Boost Software License, Version 1.0.
4  *    (See accompanying file LICENSE_1_0.txt or copy at
5  *          http://www.boost.org/LICENSE_1_0.txt)
6  */
7 
8 #include <boost/smart_ptr/shared_ptr.hpp>
9 #include <boost/move/utility_core.hpp>
10 #include <boost/log/core.hpp>
11 #include <boost/log/sources/record_ostream.hpp>
12 
13 namespace logging = boost::log;
14 
15 //[ example_core_core_manual_logging
logging_function(logging::attribute_set const & attrs)16 void logging_function(logging::attribute_set const& attrs)
17 {
18     boost::shared_ptr< logging::core > core = logging::core::get();
19 
20     // Attempt to open a log record
21     logging::record rec = core->open_record(attrs);
22     if (rec)
23     {
24         // Ok, the record is accepted. Compose the message now.
25         logging::record_ostream strm(rec);
26         strm << "Hello, World!";
27         strm.flush();
28 
29         // Deliver the record to the sinks.
30         core->push_record(boost::move(rec));
31     }
32 }
33 //]
34 
main(int,char * [])35 int main(int, char*[])
36 {
37     logging_function(logging::attribute_set());
38 
39     return 0;
40 }
41