Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » UppHub » Extended Logging Package
icon6.gif  Extended Logging Package [message #17275] Tue, 05 August 2008 14:31 Go to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
I created a package to extend the logging capabilities of Upp. I encountered a situation where I wanted to use custom log files for release programs to log Successful and Failed transfers. It is built as a singleton with lazy creation. I built it with an archiving capability so it uses Upp bz2 package to archive logs older than a user-defined time frame. There are special cases for debug and release logs so that the archiving and dating capabilities can also apply to them. Finally, there is some Topic++ documentation for it, but the in-code documentation in the header file is best. Let me know what you think.

Simple Example:
void QuickExample(){
	// Logger singleton instance created automatically and lazily on first use.	
	UppLog::LOGGER->BeginLogs();
        UppLog::LOGGER->EnableCout(UppLog::RELEASE);
	UppLog::UPPLOG(UppLog::BOTH, "This message is sent to both log files.");
	UppLog::UPPLOG(UppLog::DEBUG, "This message is sent to debug log.");
	UppLog::UPPLOG(UppLog::RELEASE, "This message is sent to release log (and Cout()).");
	
	UppLog::LOGGER->CreateLog("Successes");
	UppLog::LOGGER->CreateLog("Failures", "C:\\failures");
	UppLog::UPPLOG("Successes", "My successful transaction message.");
	UppLog::UPPLOG("Failures", "My failed transaction message.");	
};


Edit: Attachment deleted. Use the newer version below.

[Updated on: Tue, 23 September 2008 19:16]

Report message to a moderator

Re: Extended Logging Package [message #17276 is a reply to message #17275] Tue, 05 August 2008 14:50 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Really nice functionality!

But I would make it a a normal class, and if I need singleton design pattern I would just use the Single template provided by U++. And macros? There has got to be another way to do the logging without those terrible macros Smile. What if I have a function somewhere named UPPLOG or LOGGER?

But the rest is nice and I'll give it a try (after I remove the macros Smile) since I use DUMP a lot, especially under Linux, and I've been wishing for something a little more powerful.
Re: Extended Logging Package [message #17279 is a reply to message #17276] Tue, 05 August 2008 15:32 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
Quote:

if I need singleton design pattern I would just use the Single template provided by U++

Yeah, I had never used the singleton template from U++, I forgot it was even there.

Quote:

And macros? There has got to be another way to do the logging without those terrible macros

There is, but the naming makes it really long. The macros are only a shortcut for it.
You can use something like this instead:

using namespace UppLog;
Logger::Instance()->Log("mylog", "my log message");


I'll rethink the naming conventions...
Re: Extended Logging Package [message #17290 is a reply to message #17279] Tue, 05 August 2008 18:42 Go to previous message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
Changed macros to inline void functions.
Fixed bug in calculating getting seconds from time interval.
Changed massage arguments to const string references.
Sample using namespace:
using namespace UppLog;
Logger::Instance()->BeginLogs();
UPPLOG(BOTH, "log message");

Previous Topic: Shiny: C++ profiler - Ultimate++ package
Next Topic: Shared object with auto locking strategy
Goto Forum:
  


Current Time: Fri Mar 29 14:16:39 CET 2024

Total time taken to generate the page: 0.01528 seconds