12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- /*
- * 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)
- */
- /*!
- * \file main.cpp
- * \author Andrey Semashev
- * \date 07.11.2009
- *
- * \brief An example of trivial logging.
- */
- // #define BOOST_ALL_DYN_LINK 1
- // #define BOOST_LOG_DYN_LINK 1
- #include <boost/log/trivial.hpp>
- #include <boost/log/core.hpp>
- #include <boost/log/expressions.hpp>
- int main(int argc, char* argv[])
- {
- // Trivial logging: all log records are written into a file
- BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
- BOOST_LOG_TRIVIAL(debug) << "A debug severity message";
- BOOST_LOG_TRIVIAL(info) << "An informational severity message";
- BOOST_LOG_TRIVIAL(warning) << "A warning severity message";
- BOOST_LOG_TRIVIAL(error) << "An error severity message";
- BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message";
- // Filtering can also be applied
- using namespace boost::log;
- core::get()->set_filter
- (
- trivial::severity >= trivial::info
- );
- // Now the first two lines will not pass the filter
- BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
- BOOST_LOG_TRIVIAL(debug) << "A debug severity message";
- BOOST_LOG_TRIVIAL(info) << "An informational severity message";
- BOOST_LOG_TRIVIAL(warning) << "A warning severity message";
- BOOST_LOG_TRIVIAL(error) << "An error severity message";
- BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message";
- return 0;
- }
|