~aleteoryx/muditaos

ref: master muditaos/module-utils/log/log.cpp -rw-r--r-- 1.6 KiB
2cd0e472 — Lefucjusz [BH-000] Update Harmony 2.10.0 changelog 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#include <log/log.hpp>
#include <Logger.hpp>
#include <macros.h>

using Log::Logger;

int log_Printf(const char *fmt, ...)
{
    va_list args;

    // temporarily disable logs in interrupts for heap overwriting reasons
    if (isIRQ()) {
        return 0;
    }

    va_start(args, fmt);
    const int result = Logger::get().log(Log::Device::DEFAULT, fmt, args);
    va_end(args);
    return result;
}

int log_ignore(LoggerLevel level, const char *file, int line, const char *function, const char *fmt, ...)
{
    va_list args;
    va_start(args, fmt);
    va_end(args);
    return 0;
}

int log_Log(LoggerLevel level, const char *file, int line, const char *function, const char *fmt, ...)
{
    va_list args;

    // temporarily disable logs in interrupts for heap overwriting reasons
    if (isIRQ()) {
        return 0;
    }

    va_start(args, fmt);
    const int result = Logger::get().log(level, file, line, function, fmt, args);
    va_end(args);
    return result;
}

size_t log_getMaxLineLength()
{
    return Logger::get().getMaxLineLength();
}

extern "C"
{
    void bt_log_custom(const char *file, int line, const char *foo, const char *fmt, ...)
    {
        va_list args;

        // temporarily disable logs in interrupts for heap overwriting reasons
        if (isIRQ()) {
            return;
        }

        va_start(args, fmt);
        Logger::get().log(LOGTRACE, file, line, foo, fmt, args);
        va_end(args);
    }
}