Opened 8 years ago

Closed 8 years ago

#10926 closed Bugs (fixed)

Process ID insertion operator not internal filled

Reported by: Paul Long <plong@…> Owned by: Andrey Semashev
Milestone: To Be Determined Component: log
Version: Boost 1.57.0 Severity: Cosmetic
Keywords: Cc:

Description

Process ID is formatted with leading 0's rather than internal 0's (thread ID is okay). This results in a log entry like this:

13:25:26.014303 DEBUG [000000x9b8/0x00000914] Gsid.cpp(302):MakeXfer > Start main

whereas it should look like this:

13:25:26.014303 DEBUG [0x000009b8/0x00000914] Gsid.cpp(302):MakeXfer > Start main

...based on the following unsurprising code snippet.

logging::add_file_log
(
    LogFile(),
    keywords::open_mode = std::ios::out | std::ios::app,
    keywords::filter = expr::attr<severity_level>("Severity") >= MinSeverity,
    keywords::rotation_size = MaxFileSize,
    keywords::max_size = MaxFileSize * MaxBackupIndex,
    keywords::format = expr::stream
        << expr::format_date_time<boost::posix_time::ptime>("TimeStamp", TimestampFormat())
        << " " << expr::attr<severity_level>("Severity")
        << " [" << expr::attr<attrs::current_process_id::value_type>("ProcessID")
        << "/" << expr::attr<attrs::current_thread_id::value_type>("ThreadID")
        << "] " << expr::format_named_scope("Scope", keywords::format = ScopeFormat())
        << " > " << expr::message
);

boost::shared_ptr<logging::core> pCore = logging::core::get();
pCore->add_global_attribute(
    aux::default_attribute_names::timestamp(),
    attrs::local_clock());
pCore->add_global_attribute(
    aux::default_attribute_names::process_id(),
    attrs::current_process_id());
pCore->add_global_attribute("ProcessName",
    attrs::current_process_name());
pCore->add_global_attribute(
    aux::default_attribute_names::thread_id(),
    attrs::current_thread_id());
pCore->add_global_attribute("Scope", attrs::named_scope());

I believe the fix is to replace this line in libs/log/src/process_id.cpp:

io::ios_flags_saver flags_saver(strm, std::ios_base::hex | std::ios_base::showbase);

with this line:

io::ios_flags_saver flags_saver(strm, std::ios_base::hex | std::ios_base::internal | std::ios_base::showbase);

Change History (1)

comment:1 by Andrey Semashev, 8 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.