Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5db8d6aa authored by Nick Kralevich's avatar Nick Kralevich
Browse files

logging: avoid unnecessary printfs

Don't spend CPU cycles formatting a bunch of strings if we're
just going to throw them away later. Maybe make booting faster.

Change-Id: I4d8eb99fb3fa873ca91cf776933d0ad01988abf5
parent 13655cdc
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,8 @@
static void init_klog_vwrite(int level, const char* fmt, va_list ap) {
static void init_klog_vwrite(int level, const char* fmt, va_list ap) {
    static const char* tag = basename(getprogname());
    static const char* tag = basename(getprogname());


    if (level > klog_get_level()) return;

    // The kernel's printk buffer is only 1024 bytes.
    // The kernel's printk buffer is only 1024 bytes.
    // TODO: should we automatically break up long lines into multiple lines?
    // TODO: should we automatically break up long lines into multiple lines?
    // Or we could log but with something like "..." at the end?
    // Or we could log but with something like "..." at the end?
+1 −0
Original line number Original line Diff line number Diff line
@@ -62,6 +62,7 @@ void klog_writev(int level, const struct iovec* iov, int iov_count) {
}
}


void klog_write(int level, const char* fmt, ...) {
void klog_write(int level, const char* fmt, ...) {
    if (level > klog_level) return;
    char buf[LOG_BUF_MAX];
    char buf[LOG_BUF_MAX];
    va_list ap;
    va_list ap;
    va_start(ap, fmt);
    va_start(ap, fmt);