Boost logo

Boost :

Subject: Re: [boost] [log] Comments
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2010-03-16 07:19:50


Steven Watanabe wrote:
> Andrey Semashev wrote:
> > On 03/15/2010 10:50 PM, Steven Watanabe wrote:
>
> >> I guess that what I'd like is a way to specify arbitrary
> >>> attributes when
> >> logging, so BOOST_LOG_XXX would be defined like
> >>
> >> #define BOOST_LOG_XXX(lg, component, severity)
> >> BOOST_LOG_WITH_ATTRS(lg,
> >> ("Severity", severity)("Channel", component))
> >
> > That should be quite possible, if there was some way to select the
> > attributes from the rest of the named parameters for the logger.
> > Although that would mean the attributes are added/removed from the
> > logger at each record.
>
> You might be able to create special keywords that
> are associated with attribute names.

That reminds me. Seeing the strings in the library's interface such as proposed above make me nervous. In our environment, logging has to be very low latency in the calling thread. Checking to see whether a severity/component is enabled has to be very fast. Strings, such as those appearing in the suggestion above, imply higher latency than ideal.

It would be really nice to have a string-to-ID mapping whereby the attribute names can be turned into identifiers that can be used thereafter for constant time lookup. In the example above, an extern std::size_t, say, would hold the ID for "Severity" and another for "Channel." Then, the macro would reference those std::size_t's rather than the strings, making all uses of that macro much faster.

Adding support for that approach would, most likely, increase the API by adding overloads to various functions because the simpler, string-based approach may be adequate for many applications.

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


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