Boost logo

Boost :

Subject: Re: [boost] Boost::log query
From: Rajpal Dangi (rajpal.dangi_at_[hidden])
Date: 2008-09-03 16:38:36


Rephrasing my second question from previous post.
Suppose NORMAL, ERROR and CRITICAL severity logs are directed to text
file. How to identify which one of them belong to ERROR severity?

I understand this can be done by using attribute (Tags in example) but
I'm looking something implicit. So that we can avoid call to
BOOST_LOG_SCOPED_LOGGER_TAG for each BOOST_LOG_SEV call.

What I meant by print severity in log file is to have severity level as
part of log file contents i.e.
For BOOST_LOG_SEV(my_crit_logger, NORMAL)
    << "This record is explicitly marked as to NORMAL";

Log file contents:
......[NORMAL] This record is explicitly marked as to NORMAL

In other words

-----Original Message-----
From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]] On Behalf Of Andrey Semashev
Sent: Wednesday, September 03, 2008 12:51 PM
To: boost_at_[hidden]
Subject: Re: [boost] Boost::log query

Rajpal Dangi wrote:
> While using rotating text file as stream, is it possible to keep most
> recent log file name same all the time? Currently what I observe is
'N'
> keeps incrementing and have to manually find out the most recent file.

No, the stream always generates a new file name on rotation and uses it
to write the log to. Therefore, the mos recent log file is the one with
the last counter value.

The rationale for such behavior is that there are considerably more
possibilities for the rotation to fail, if done as you suggest. It is
possible that the current log file gets locked by another process, in
which case it is not clear where to write logs to. Also, if keeping the
current log file name the same, it would be necessary to provide at
least two file name templates to the stream: one for the current file
name and another to form up the rotated file names. This would
complicate the stream usage.

> Also,
> is there some way to print severity in log file without explicitly
> passing it as part of message i.e. BOOST_LOG_SEV(my_logger, CRITICAL)

Yes, you can provide the default severity level to the logger
constructor. Having done that, all log records that are written through
this logger without an explicit severity level specification will have
the default level. For example:

  severity_logger my_crit_logger(keywords::severity = CRITICAL);

  BOOST_LOG(my_crit_logger) << "The record is CRITICAL by default";
  BOOST_LOG_SEV(my_crit_logger, NORMAL)
    << "This record is explicitly marked as to NORMAL";
_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk