The logging service crashed so often that monitoring started treating it as the baseline. Root cause: file descriptors leak from every early return — the author considered fclose 'optional'. The author has left the company; the descriptors haven't. Wrap the file in a RAII handle so it closes itself no matter what.
Implement a FileHandle class that wraps a raw FILE* and guarantees the file is always closed — even when exceptions are thrown. The class must be movable but not copyable.
noexcept important on move operations?Open the file in the constructor with fopen, store the FILE*, and fclose it in the destructor if non-null.
The move constructor should steal the pointer and set the source's pointer to nullptr so it won't double-close.
Hit Submit (or ⌘/Ctrl + ↵) — test results will show up here.