Boost logo

Boost :

From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2008-08-31 05:07:29


On Sat, 2008-08-30 at 23:16 -0700, Igor Nazarenko wrote:
> By default, severity is printed as integer. What's the easiest way to
> print the corresponding string (e.g. "info" for severity 0, "warn" for
> severity 1, and so on)?
>
> I tried defining operator<< for my severity enum, but
> attr<severity_level> doesn't work; that is, the output operator
> doesn't get invoked (I assume because attribute "Severity" is
> internally of type "int" and not of my enum type).

Yes, the severity level is stored as an int, and therefore the attr
formatter uses operator<< for ints. Right now you can either define your
own formatter that will accept an int and transform it into a string, or
develop your own attribute and logger to store the level as an enum
(then the attr formatter should be used with explicitly specified enum
type).

I haven't decided yet how to solve this problem best in the library.


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