123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- /*
- * Copyright Andrey Semashev 2007 - 2015.
- * Distributed under the Boost Software License, Version 1.0.
- * (See accompanying file LICENSE_1_0.txt or copy at
- * http://www.boost.org/LICENSE_1_0.txt)
- */
- #include <boost/log/trivial.hpp>
- #include <boost/log/sources/severity_logger.hpp>
- #include <boost/log/sources/record_ostream.hpp>
- #include <boost/log/utility/setup/file.hpp>
- #include <boost/log/utility/setup/common_attributes.hpp>
- namespace logging = boost::log;
- namespace src = boost::log::sources;
- namespace keywords = boost::log::keywords;
- //[ example_tutorial_formatters_string
- void init()
- {
- logging::add_file_log
- (
- keywords::file_name = "sample_%N.log",
- keywords::format = "[%TimeStamp%]: %Message%"
- );
- }
- //]
- int main(int, char*[])
- {
- init();
- logging::add_common_attributes();
- using namespace logging::trivial;
- src::severity_logger< severity_level > lg;
- BOOST_LOG_SEV(lg, trace) << "A trace severity message";
- BOOST_LOG_SEV(lg, debug) << "A debug severity message";
- BOOST_LOG_SEV(lg, info) << "An informational severity message";
- BOOST_LOG_SEV(lg, warning) << "A warning severity message";
- BOOST_LOG_SEV(lg, error) << "An error severity message";
- BOOST_LOG_SEV(lg, fatal) << "A fatal severity message";
- return 0;
- }
|