Menu ▾ ▴

#7 Empty lines between log entries under Windows

open
Run time (4)
3
2009-10-27
2009-10-27
whatis777
No

When using log4qt under Windows, it produces an empty line between two logger entries. This problem does not occur when using log4qt under Linux.

This problem can be reproduced under Windows in Eclipse CDT Console (console logger) and also when opening log files with certain editors: some text editors display an empty line between the entries and some do not.
I gues this is a problem with the different "new line" control characters for windows and linux.

Discussion

  • whatis777

    whatis777 - 2009-10-27
    • priority: 5 --> 3
     
  • Bordo

    Bordo - 2009-11-11

    It is according to QIODevice::Text documentation: "When reading, the end-of-line terminators are translated to '\n'. When writing, the end-of-line terminators are translated to the local encoding, for example '\r\n' for Win32."

    So here is the patch:

    diff --git a/thirdparty/log4qt/src/log4qt/layout.cpp b/thirdparty/log4qt/src/log4qt/layout.cpp
    index 160f80d..ac8bde2 100644
    --- a/thirdparty/log4qt/src/log4qt/layout.cpp
    +++ b/thirdparty/log4qt/src/log4qt/layout.cpp
    @@ -74,7 +74,7 @@ namespace Log4Qt
    // There seams to be no function in Qt for this

    #ifdef Q_OS_WIN32
    - return QLatin1String("\r\n");
    + return QLatin1String("\n");
    #endif // Q_OS_WIN32
    //#ifdef Q_OS_MAC
    // return QLatin1String("\r");

    BTW, does anybody knows how to attach pathes as files?

     
  • whatis777

    whatis777 - 2009-11-13

    Thanks bordo,

    Using \n instead of \n\r in file layout.cpp solved the problem! All MS Windows editors display the logs correctly without any empty lines.

    @martin: could you include this solution in the next release, please?

    Have a nice day,
    Manfred

     
  • Martin Heinrich

    Martin Heinrich - 2009-11-15

    Thanks to both of you for reporting and resolving the issue. I will definitely put it in.

    Cheers
    Martin

     

Log in to post a comment.