Very simple logging functionality


Hello mates,

You have given lot to us, with your customized idea. Thanks for all your works.
I know this is really simple and easy what I am sharing. But if any one wants to use very simple logging functionality without any ASync & Thread. You can use this two attached files… and follow the steps given below

How to use:
[list]#Include “LogWindow.h” file in your header of MainWindow.h or MainComponent.h
Create LogWindow * m_pLogWindow; in your header of MainWindow.h or MainComponent.h
Create one local LogComponent, and AppLgger as shown below in constructor of MainWindow or MainComponent
From that point onwards Whatever you write in Logger::writeToLog() … Will be added to your logs
On some button or menu show your log window by m_pLogWindow->setVisible(true);[/list]

In Constructor

if(m_pLogWindow == 0L)
        LogComponent * logComp = new LogComponent();
        logComp->setSize(600, 400);
        m_pLogWindow = new LogWindow("Logger Window, Colours::lightgrey, DocumentWindow::closeButton, true );
        m_pLogWindow ->setContentComponent(logComp, false, true);
		m_pLogWindow ->setResizeLimits (600,400,1000, 800);
        m_pLogWindow ->setCentrePosition( 600,400 );
        m_pLogWindow ->setResizable( true, true);
        // Create your logger
        m_pAppLogger = new AppLogger(logComp);
        Logger::setCurrentLogger(m_pAppLogger);//this function will not delete the appLogger object, hence need to store it to delete later.

In destructor

// delete your logger Logger::setCurrentLogger(NULL); delete m_pAppLogger; m_pAppLogger = NULL; // delete your log window delete m_pLogWindow; m_pLogWindow = 0;

Thanks for your interest. Yup I know it’s very basic. But useful to get logs in simple application. Have Fun…


This is how it look like if any one want quick view of it.