[libj6] Add formatting j6::syslog wrapper for j6_log

To replace all the places where snprintf/j6_log are called with buffers
on the stack for most frames.
This commit is contained in:
Justin C. Miller
2023-02-20 11:01:45 -08:00
parent cca8e8b3ad
commit abe7fe37d0
3 changed files with 43 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
// The kernel depends on libj6 for some shared code,
// but should not include the user-specific code.
#ifndef __j6kernel
#include <util/format.h>
#include <j6/syscalls.h>
namespace j6 {
void
syslog(const char *fmt, ...)
{
char buffer[200];
va_list va;
va_start(va, fmt);
size_t n = util::vformat({buffer, sizeof(buffer) - 1}, fmt, va);
va_end(va);
buffer[n] = 0;
j6_log(buffer);
}
} // namespace j6
#endif // __j6kernel