
Hi Phil,
Dear All,
I've decided to port one of my apps to the proposed logging library so that I can write a review. A couple of issues have come up immediately:
- This program currently logs using syslog. I was expecting to find a back-end for this logging library for syslog, since it is the standard logging mechanism on POSIX. But I can't see anything. Am I missing something, or is it really not there?
At this time I don't have syslog support - but it should be easy to add. I'm a Windows kind of guy, even though I tested my lib on Linux as well.
- I spent a while trying to work out how to compile the library. I have now come to the conclusion that it is header-only, and that it's only the tests and the examples (called "scenarios") that you might want to compile by following the instructions in the documentation. Is this right?
Yes, it is header-only.
From what I can see so far, using this library is not going to be a compelling alternative to the concise
#include <syslog.h> syslog(LOG_WARN,"Blob %d failed to %s",n,x);
Why not? If you say that writing to syslog is that easy, then adding a formater class for syslog should be as easy as what I've just attached. It should work out of the box, but I haven't tested it. Please let me know if it works. I've looked here: http://www.opengroup.org/onlinepubs/009695399/functions/syslog.html Does it handle Unicode (it doesn't seem to)? To add this as a destination, you should call something similar, on your logger: g_l()->writer().add_destination( destination::syslog_no_levels() ); Limitations: - it does NOT care about levels - at this time, it logs everything as LOG_INFO - to care about levels, it's a bit more complicated - I'll post another email in about 10-15 minutes. Best, John -- http://John.Torjo.com -- C++ expert http://blog.torjo.com ... call me only if you want things done right // destination/syslog_no_levels.hpp // Boost Logging library // // Author: John Torjo, www.torjo.com // // Copyright (C) 2007 John Torjo (see www.torjo.com for email) // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org for updates, documentation, and revision history. // See http://www.torjo.com/log2/ for more details #ifndef JT28092007_destination_syslog_no_levels_HPP_DEFINED #define JT28092007_destination_syslog_no_levels_HPP_DEFINED #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include <boost/logging/detail/fwd.hpp> #include <boost/logging/detail/manipulator.hpp> #include <boost/logging/format/destination/convert_destination.hpp> #include <boost/logging/format/destination/file.hpp> #include <syslog.h> namespace boost { namespace logging { namespace destination { /** @brief Writes the string to syslog_no_levels. Note: does not care about levels - always logs as LOG_INFO */ template<class convert_dest = do_convert_destination > struct syslog_no_levels_t : is_generic, boost::logging::op_equal::always_equal { template<class msg_type> void operator()(const msg_type & msg) const { syslog( LOG_INFO, msg.c_str() ); } }; /** @brief syslog_no_levels_t with default values. See syslog_no_levels_t @copydoc syslog_no_levels_t */ typedef syslog_no_levels_t<> syslog_no_levels; }}} #endif