Exemple #1
0
void FileAppender::updateHook()
{
    // \todo use v2.0 data flow to trigger this when new data is available

    if (!log_port.connected()) return;      // no category connected to us

    /* Consume waiting events until
       a) the buffer is empty
       b) we consume too many events on one cycle
     */
    OCL::logging::LoggingEvent   event;
    assert(appender);
    assert(0 <= maxEventsPerCycle);
    if (0 == maxEventsPerCycle)
    {
        // consume infinite events
        for (;;)
        {
            if (log_port.read( event ) == NewData)
            {
                log4cpp::LoggingEvent   e2 = event.toLog4cpp();
                appender->doAppend(e2);
            }
            else
            {
                break;      // nothing to do
            }
        }
    }
    else
    {

        // consume up to maxEventsPerCycle events
        int n       = maxEventsPerCycle;
        do
        {
            if (log_port.read( event ) == NewData)
            {
                log4cpp::LoggingEvent   e2 = event.toLog4cpp();
                appender->doAppend(e2);
            }
            else
            {
                break;      // nothing to do
            }
            --n;
        }
        while (0 < n);
    }
}
void OstreamAppender::updateHook()
{
    if (!log_port.connected()) return;      // no category connected to us

    OCL::logging::LoggingEvent   event;
    if (log_port.read( event ) == NewData)
    {
        log4cpp::LoggingEvent   e2 = event.toLog4cpp();
        assert(appender);
        appender->doAppend(e2);
    }
}