pocoproject / poco

The POCO C++ Libraries are powerful cross-platform C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.
https://pocoproject.org
Other
8.05k stars 2.11k forks source link

LogFile uses FileOutputStream instead of custom platform implementations (#4431) #4484

Closed matejk closed 4 months ago

matejk commented 4 months ago

4431.

FileOutputStream implements platform specific streams that are used by LogFile. There is no need to have additional platform specific implementations.

The only missing functionality in FileStream was flushing to disk.

Flushing on Posix vs Win32 was semantically different (iostream flush vs file system flush and was resolved in #4429). Flush option now means file system flush.

Since file system flush has major impact on write performance, the default flush setting is now false.

obiltschnig commented 4 months ago

Note that there's also a difference in line endings on Windows. FileOutputStream always uses \n only. The Windows-specific LogFile also properly translates \n to \r\n. So this will break things on Windows.

matejk commented 4 months ago

Thanks, @obiltschnig. I missed that detail.

I replaced hardcoded '\n' with POCO_DEFAULT_NEWLINE_CHARS.

While I am at it:

Shall Windows line endings be converted to Unix in the same manner when writing to a log file?