[Box Backup-dev] Logging
Chris Wilson
boxbackup-dev at fluffy.co.uk
Sun Dec 25 01:06:50 GMT 2005
Hi Martin,
> Sounds like a great plan to me. I was going to propose something in that
> direction when converting from printf to streams. Maybe we could do that
> transition in one go.
That would be a good idea, although it might make the design a little more
complex. Rather than using varargs, how about the Log::Log function
just takes a stringstream object as a parameter? Then you could write:
std::ostringstream msg;
msg << "Failed to open file " << filename;
Log::Log(Log::ERROR, msg);
Alternatively, we could make a class of log messages that o
has (overloaded) append methods, and a log(priority) method, so you could
write:
Log::Message msg;
msg.append("Failed to open file ").append(filename);
msg.log(Log::ERROR)
Or even:
Log::Message(Log::ERROR, "Failed to open file ", filename);
where the overloaded constructors (different numbers of string arguments)
call Log::Log(this) automatically? What do people prefer? I guess Ben
might like the latter as it avoids the use of overloaded operator<<.
> log4cxx is a good place to look if you need any further inspiration on
> how to do this. It does (almost?) everything you list and much more. I
> doubt Ben would want to use it directly because it would introduce more
> dependencies (it itself is dependent on boost).
I based this idea on Log4j, which I guess is similar to log4cxx, but also
assuming that Ben wouldn't want to include the whole of log4cxx, or to
bloat the logging framework more than necessary.
Cheers, Chris.
--
_ ___ __ _
/ __/ / ,__(_)_ | Chris Wilson <0000 at qwirx.com> - Cambs UK |
/ (_/ ,\/ _/ /_ \ | Security/C/C++/Java/Perl/SQL/HTML Developer |
\ _/_/_/_//_/___/ | We are GNU-free your mind-and your software |
More information about the Boxbackup-dev
mailing list