Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
March 13, 2008 Function name as part of message (pantheios) | ||||
---|---|---|---|---|
| ||||
Does Pantheios provide a configuration that yields a logged message containing the containing function? Aka log(informational, __FUNCTION__, ": my message"); just without having to write that (or some wrapper like XTESTS_GET_FUNCTION that checks for compiler support). Lars Ivar |
March 13, 2008 Re: Function name as part of message (pantheios) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | Yes indeed. Check out the Pantheios Tracing API, defined in include/pantheios/trace.h, and the example in examples/cpp/example.cpp.tracing/example.cpp.tracing.cpp Matt "Lars Ivar Igesund" <larsivar@igesund.net> wrote in message news:frb88h$1d2n$1@digitalmars.com... > Does Pantheios provide a configuration that yields a logged message containing the containing function? > > Aka > log(informational, __FUNCTION__, ": my message"); > > just without having to write that (or some wrapper like XTESTS_GET_FUNCTION that checks for compiler support). > > Lars Ivar |
March 13, 2008 Re: Function name as part of message (pantheios) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | Matthew Wilson wrote: > Yes indeed. > > Check out the Pantheios Tracing API, defined in include/pantheios/trace.h, and the example in examples/cpp/example.cpp.tracing/example.cpp.tracing.cpp I am probably blind, but this provides the filename and line number instead of function name? > > Matt > > "Lars Ivar Igesund" <larsivar@igesund.net> wrote in message news:frb88h$1d2n$1@digitalmars.com... >> Does Pantheios provide a configuration that yields a logged message > containing the containing function? >> >> Aka >> log(informational, __FUNCTION__, ": my message"); >> >> just without having to write that (or some wrapper like > XTESTS_GET_FUNCTION that checks for compiler support). >> >> Lars Ivar -- Lars Ivar Igesund blog at http://larsivi.net DSource, #d.tango & #D: larsivi Dancing the Tango |
March 14, 2008 Re: Function name as part of message (pantheios) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | Gah! Sorry It was part of the original design to do this, and I answered your email at an unBobbly hour. I will attend to this and illustrate the way to use it to achieve what you want in a couple of hours. Cheers Matt "Lars Ivar Igesund" <larsivar@igesund.net> wrote in message news:frc8bc$1fmo$1@digitalmars.com... > Matthew Wilson wrote: > > > Yes indeed. > > > > Check out the Pantheios Tracing API, defined in include/pantheios/trace.h, > > and the example in examples/cpp/example.cpp.tracing/example.cpp.tracing.cpp > > I am probably blind, but this provides the filename and line number instead > of function name? > > > > > Matt > > > > "Lars Ivar Igesund" <larsivar@igesund.net> wrote in message news:frb88h$1d2n$1@digitalmars.com... > >> Does Pantheios provide a configuration that yields a logged message > > containing the containing function? > >> > >> Aka > >> log(informational, __FUNCTION__, ": my message"); > >> > >> just without having to write that (or some wrapper like > > XTESTS_GET_FUNCTION that checks for compiler support). > >> > >> Lars Ivar > > -- > Lars Ivar Igesund > blog at http://larsivi.net > DSource, #d.tango & #D: larsivi > Dancing the Tango |
March 14, 2008 Re: Function name as part of message (pantheios) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | Here we go: You just need to #define PANTHEIOS_TRACE_PREFIX to what you want. By default it is __FILE__ "(" PANTHEIOS_STRINGIZE(__LINE__) "): " (ie. "<file>(<line>): ") For function, lets says you want it to be (ie. "<file>(<line>): <func>: "). In that case you'd define it as follows: #include <pantheios/pantheios.h> #define PANTHEIOS_TRACE_PREFIX __FILE__ " " PANTHEIOS_STRINGIZE(__LINE__) ": " __FUNCTION__ ": " #include <pantheios/trace.h> Note that the definition *must* come before the inclusion of pantheios/trace.h. Therefore, a safer way of doing this is as follows: /* File: myPantheiosRootHeader.h */ #include <pantheios/pantheios.h> #ifdef PANTHEIOS_INCL_PANTHEIOS_H_TRACE # error pantheios/trace.h must not be included before myPantheiosRootHeader.h #endif /* PANTHEIOS_INCL_PANTHEIOS_H_TRACE */ #define PANTHEIOS_TRACE_PREFIX __FILE__ " " PANTHEIOS_STRINGIZE(__LINE__) ": " __FUNCTION__ ": " #include <pantheios/trace.h> HTH Matt "Matthew Wilson" <matthew@hat.stlsoft.dot.org> wrote in message news:frdfq5$1s07$1@digitalmars.com... > Gah! Sorry > > It was part of the original design to do this, and I answered your email at > an unBobbly hour. > > I will attend to this and illustrate the way to use it to achieve what you want in a couple of hours. > > Cheers > > Matt > > "Lars Ivar Igesund" <larsivar@igesund.net> wrote in message news:frc8bc$1fmo$1@digitalmars.com... > > Matthew Wilson wrote: > > > > > Yes indeed. > > > > > > Check out the Pantheios Tracing API, defined in > include/pantheios/trace.h, > > > and the example in examples/cpp/example.cpp.tracing/example.cpp.tracing.cpp > > > > I am probably blind, but this provides the filename and line number > instead > > of function name? > > > > > > > > Matt > > > > > > "Lars Ivar Igesund" <larsivar@igesund.net> wrote in message news:frb88h$1d2n$1@digitalmars.com... > > >> Does Pantheios provide a configuration that yields a logged message > > > containing the containing function? > > >> > > >> Aka > > >> log(informational, __FUNCTION__, ": my message"); > > >> > > >> just without having to write that (or some wrapper like > > > XTESTS_GET_FUNCTION that checks for compiler support). > > >> > > >> Lars Ivar > > > > -- > > Lars Ivar Igesund > > blog at http://larsivi.net > > DSource, #d.tango & #D: larsivi > > Dancing the Tango > > |
Copyright © 1999-2021 by the D Language Foundation