Index: src/OFStdIOStream.h ================================================================== --- src/OFStdIOStream.h +++ src/OFStdIOStream.h @@ -150,16 +150,24 @@ * @brief The standard error as an OFStream. */ extern OFStdIOStream *_Nullable of_stderr; /*! - * @brief Log the specified printf-style format to @ref of_stderr. + * @brief Logs the specified printf-style format to @ref of_stderr. * * This prefixes the output with the date, timestamp, process name and PID and * allows `%@` as a printf-style formatted to print objects. */ extern void of_log(OFConstantString *format, ...); + +/*! + * @brief Logs the specified printf-style format to @ref of_stderr. + * + * This prefixes the output with the date, timestamp, process name and PID and + * allows `%@` as a printf-style formatted to print objects. + */ +extern void of_logv(OFConstantString *format, va_list arguments); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -72,27 +72,34 @@ #endif void of_log(OFConstantString *format, ...) { + va_list arguments; + + va_start(arguments, format); + of_logv(format, arguments); + va_end(arguments); +} + +void +of_logv(OFConstantString *format, va_list arguments) +{ void *pool = objc_autoreleasePoolPush(); OFDate *date; OFString *dateString, *me, *msg; - va_list arguments; date = [OFDate date]; dateString = [date localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"]; #ifdef OF_HAVE_FILES me = [OFApplication programName].lastPathComponent; #else me = [OFApplication programName]; #endif - va_start(arguments, format); msg = [[[OFString alloc] initWithFormat: format arguments: arguments] autorelease]; - va_end(arguments); [of_stderr writeFormat: @"[%@.%03d %@(%d)] %@\n", dateString, date.microsecond / 1000, me, getpid(), msg]; objc_autoreleasePoolPop(pool);