Overview
Features
Download
Documentation
Community
Add-Ons & Services

Bug: Poco::FileChannel::open() and actual file creation

Please post support and help requests here.

Bug: Poco::FileChannel::open() and actual file creation

Postby Paranaix » 20 Jan 2014, 16:25

I am using Poco 1.5.2 under windows 7.

From the Poco::FileChannel::open() documentation:
Opens the FileChannel and creates the log file if necessary.


And from the Poco::Channel::open() documentation:
Does whatever is necessary to open the channel.


The problem here is that the open() function does not create the logfile at all (if it does not exist) but just a Poco::LogFile object. The creation of the actual logfile is delayed to the first write to the file. This is a major issue not just because it violates the conditions stated in the documentation IMO, but also because a simple log (which can occur minutes after the application and the logging have been intialized) can trigger the creation of the file. If this creation fails though an Poco::OpenFileException is thrown. We cant however force the creation of the file like this:
Code: Select all
    try
    {
        fileChannel->open();
        splitterChannel->addChannel(fileChannel);
    }
    catch (const Poco::OpenFileException& exc)
    {
        poco_error(logger, "Cant open logfile");
    }


This means that error checking becomes really a pain in the ass, or do you want to put a try-block around every log statement (besides that the "log/logger" theoretically does not know what exceptions his channels might throw) ?
Of course we can solve this by executing a pseodo log guranteed to be the first log during the initialization of the logging framework:
Code: Select all
try
    {
        fileChannel->log(Poco::Message());
        splitterChannel->addChannel(fileChannel);
    }
    catch (const Poco::OpenFileException& exc)
    {
        poco_error(logger, "Cant open logfile");
    }


But I think its obviously that this isnt good design (this btw leaves a blank line in the file). Atleast myself spent atleast 1 hour with this.

I hope that this will be fixed before release
Paranaix
 
Posts: 4
Joined: 08 Jan 2012, 21:52

Return to Support

Who is online

Users browsing this forum: No registered users and 4 guests