
----- "Tigran Hayrapetyan" <tigran.human@gmail.com> a écrit :
Hello dear Boost community
(...)
Existing logging libraries which I used, are writing log messages linearly, just one after another. In contrast, as we know, almost any application's working structure is not linear, but hierarchical instead, i.e. functions which call other functions, and so on. (...) So I decided to implement such logging library. I put it in namespace "tlog" by now, for "Tree Logging". In my implementation hierarchical messages are presented in XML format, as it is some standard for tree-like data. There are two attached files. The library itself is in "tlog.hpp" file, and "main.cpp" contains a sample application which is using the library and writes log to "tlog.xml" file. They are written in MS Visual Studio 2008. Log messages are written with help of 4 macros:
TLOG_INFO( Logger, Text ) : logs message with specified text to specified logger with priority "information" TLOG_WARNING( Logger, Text ) : logs message with specified text to specified logger with priority "warning" TLOG_ERROR( Logger, Text ) : logs message with specified text to specified logger with priority "error" TLOG_SCOPED_NODE( Logger, NodeName ) : opens xml element in the log file. The element will be closed at the end of scope, so there is no need to close it manually.
I think that the best way to implement entering/leaving subnodes of the log file, is to use scopes of the code.
Please review run result and the code, and see if it can be useful for boost.
Have you tried Boost.Log and its attributes ? http://boost-log.sourceforge.net/libs/log/doc/html/log/detailed/attributes.h... http://boost-log.sourceforge.net/libs/log/doc/html/log/detailed/utilities.ht... Ivan

----- "Tigran Hayrapetyan" <tigran.human@gmail.com> a écrit :
Hello dear Boost community
(...) Existing logging libraries which I used, are writing log messages linearly, just one after another. In contrast, as we know, almost any application's working structure is not linear, but hierarchical instead, i.e. functions which call other functions, and so on. (...)
Have you tried Boost.Log and its attributes ?
http://boost-log.sourceforge.net/libs/log/doc/html/log/detailed/attributes.html#log.detailed.attributes.named_scope<http://boost-log.sourceforge.net/libs/log/doc/html/log/detailed/attributes.html#log.detailed.attributes.named_scope> http://boost-log.sourceforge.net/libs/log/doc/html/log/detailed/utilities.html#log.detailed.utilities.scoped_attributes<http://boost-log.sourceforge.net/libs/log/doc/html/log/detailed/utilities.html#log.detailed.utilities.scoped_attributes>
Ivan
As I understand, that features of Boost.Log library are for managing attributes of log messages, and not log messages (or their placements) themselves. So the log messages are still placed linearly, and my proposal is to place them hierarchically. Tigran

----- "Tigran Hayrapetyan" <tigran.human@gmail.com> a ?crit :
----- "Tigran Hayrapetyan" <tigran.human@gmail.com> a ?crit :
Hello dear Boost community
(...) Existing logging libraries which I used, are writing log messages linearly, just one after another. In contrast, as we know, almost any application's working structure is not linear, but hierarchical instead, i.e. functions which call other functions, and so on. (...)
Have you tried Boost.Log and its attributes ?
http://boost-log.sourceforge.net/libs/log/doc/html/log/detailed/attributes.h...
http://boost-log.sourceforge.net/libs/log/doc/html/log/detailed/utilities.ht...
As I understand, that features of Boost.Log library are for managing attributes of log messages, and not log messages (or their placements) themselves. So the log messages are still placed linearly, and my proposal is to place them hierarchically.
NB: I'm not a Boost.Log expert at all. I was only curious.
And my understanding is that how to handle attributes is left to the sink backend. I would try writing a new sink backend that handles a named_scope attribute. http://boost-log.sourceforge.net/libs/log/doc/html/log/extension.html#log.extension.sinks<http://boost-log.sourceforge.net/libs/log/doc/html/log/extension.html#log.extension.sinks>
I'm also new to Boost.Log library. I didn't knew that such library exists in Boost as it is not an official part of Boost libraries collection<http://www.boost.org/> . However, I think also that custom sink backends probably can provide same functionality as my header file. I will try it too. Thanks, Tigran
participants (2)
-
Ivan Le Lann
-
Tigran Hayrapetyan