From: Christian P. <cp...@se...> - 2005-01-11 15:55:40
|
Hi List ! I've added the re-worked logging framework from P1 to P2's CVS. LogMessage: Log message class (stores severity, timestamp and log msg). LogChannel: Log message channel/stream. Output's messages to targets registered with the LogChannel. Keeps per-thread stream-state. LogTarget: The LogTarget output's the LogMessage's (zB. to file, socket, ...). LogManager: Logging Manager, makes life easier, keeps track of LogChannels and LogTargets. Client usage: -- snip -- // get instance to the LogManager LogManager& mgr = LogManager::instance(); // add a global log channel LogChannel* globalChan = mgr.addChannel("global"); // add a LogTarget of type ConsoleLogTarget to the globalChan LogChannel // The LogTarget is created by the PluginManager and owned by the LogManager. LogTarget* target = mgr.addTarget(globalChan, "console", "ConsoleLogTarget"); if(!target) return; // open target target->open(URL("stdin://")); // we may now send messages to the LogChannel ... (*globalChan) << "Hello world!" << endl; // change message level to Critical and send next log message (*globalChan)(LogMessage::Critical) << "Bush sucks!" << endl; mgr("global") << "Even simpler ... but slower" << endl; -- snip -- Of course, the client is allowed to directly add LogTargets to LogChannels. However, the LogManager does not care about deleting manually added LogTargets. The first LogTarget plugin is already in CVS: ConsoleLogTarget [alias: Console] Have a nice day! Greetings, Christian |