[Boost Log] how to print source code file name and line number in boost log
Boost version: 1.55.0
OS: Windows 8
IDE: Visual Studio 2010
Boost Module: Boost Log
I'm using Boost Logging in my C++ application. I have been able to
generate log of this format
[2014-Jul-15 10:47:26.137959]: <debug> A regular message
I want to be able to add source file name and line number where the log is
generated, But i'm not able to do so.
[2014-Jul-15 10:47:26.137959]: <debug> [filename:line_no] A regular message
example:
[2014-Jul-15 10:47:26.137959]: <debug> [helloworld.cpp : 12] A regular message
Source Code:
#include
*/ keywords::format = ( boost::log::expressions::stream << boost::log::expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d_%H:%M:%S.%f") << ": <" << boost::log::trivial::severity << "> " << boost::log::expressions::smessage ) );} int main(int, char*[]){ init(); logging::add_common_attributes();
using namespace logging::trivial; src::severity_logger< severity_level > lg; BOOST_LOG_SEV(lg, debug) << "A regular message"; return 0;}
participants (1)
-
Pritesh Acharya