core_core_manual.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #include <boost/smart_ptr/shared_ptr.hpp>
  8. #include <boost/move/utility_core.hpp>
  9. #include <boost/log/core.hpp>
  10. #include <boost/log/sources/record_ostream.hpp>
  11. namespace logging = boost::log;
  12. //[ example_core_core_manual_logging
  13. void logging_function(logging::attribute_set const& attrs)
  14. {
  15. boost::shared_ptr< logging::core > core = logging::core::get();
  16. // Attempt to open a log record
  17. logging::record rec = core->open_record(attrs);
  18. if (rec)
  19. {
  20. // Ok, the record is accepted. Compose the message now.
  21. logging::record_ostream strm(rec);
  22. strm << "Hello, World!";
  23. strm.flush();
  24. // Deliver the record to the sinks.
  25. core->push_record(boost::move(rec));
  26. }
  27. }
  28. //]
  29. int main(int, char*[])
  30. {
  31. logging_function(logging::attribute_set());
  32. return 0;
  33. }