Index: src/OFStdIOStream.h ================================================================== --- src/OFStdIOStream.h +++ src/OFStdIOStream.h @@ -148,16 +148,27 @@ * @brief The standard error as an OFStream. */ extern OFStdIOStream *_Nullable OFStdErr; /** - * @brief Log the specified printf-style format to @ref OFStdErr. + * @brief Logs the specified printf-style format to @ref OFStdErr. + * + * This prefixes the output with the date, timestamp, process name and PID. * - * This prefixes the output with the date, timestamp, process name and PID and - * allows `%@` as a printf-style formatted to print objects. + * @param format The format for the line to log. See @ref OFStream#writeFormat:. */ extern void OFLog(OFConstantString *format, ...); + +/** + * @brief Logs the specified printf-style format to @ref OFStdErr. + * + * This prefixes the output with the date, timestamp, process name and PID. + * + * @param format The format for the line to log. See @ref OFStream#writeFormat:. + * @param arguments The arguments for the format + */ +extern void OFLogV(OFConstantString *format, va_list arguments); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -75,27 +75,34 @@ #endif void OFLog(OFConstantString *format, ...) { + va_list arguments; + + va_start(arguments, format); + OFLogV(format, arguments); + va_end(arguments); +} + +void +OFLogV(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); [OFStdErr writeFormat: @"[%@.%03d %@(%d)] %@\n", dateString, date.microsecond / 1000, me, getpid(), msg]; objc_autoreleasePoolPop(pool);