aboutsummaryrefslogtreecommitdiff
path: root/base/include/aemu/base/logging/CLog.h
blob: 9a7959a4bf64950894208cf2c69aca896372f065 (plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* Copyright (C) 2007-2008 The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

#pragma once

#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

#include "aemu/base/logging/LogSeverity.h"

#ifdef _MSC_VER
#ifdef LOGGING_API_SHARED
#define LOGGING_API __declspec(dllexport)
#else
#define LOGGING_API __declspec(dllimport)
#endif
#else
#define LOGGING_API
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
    kLogDefaultOptions = 0,
    kLogEnableDuplicateFilter = 1,
    kLogEnableTime = 1 << 2,
    kLogEnableVerbose = 1 << 3,
} LoggingFlags;

// Enable/disable verbose logs from the base/* family.
LOGGING_API void base_enable_verbose_logs();
LOGGING_API void base_disable_verbose_logs();

LOGGING_API void verbose_enable(uint64_t tag);
LOGGING_API void verbose_disable(uint64_t tag);
LOGGING_API bool verbose_check(uint64_t tag);
LOGGING_API bool verbose_check_any();
LOGGING_API void set_verbosity_mask(uint64_t mask);
LOGGING_API uint64_t get_verbosity_mask();

// Configure the logging framework.
LOGGING_API void base_configure_logs(LoggingFlags flags);
LOGGING_API void __emu_log_print(LogSeverity prio, const char* file, int line, const char* fmt,
                                 ...);

#ifndef EMULOG
#define EMULOG(priority, fmt, ...) \
    __emu_log_print(priority, __FILE__, __LINE__, fmt, ##__VA_ARGS__);
#endif

// Logging support.
#define dprint(fmt, ...)                               \
    if (EMULATOR_LOG_DEBUG >= getMinLogLevel()) {      \
        EMULOG(EMULATOR_LOG_DEBUG, fmt, ##__VA_ARGS__) \
    }

#define dinfo(fmt, ...)                               \
    if (EMULATOR_LOG_INFO >= getMinLogLevel()) {      \
        EMULOG(EMULATOR_LOG_INFO, fmt, ##__VA_ARGS__) \
    }
#define dwarning(fmt, ...)                               \
    if (EMULATOR_LOG_WARNING >= getMinLogLevel()) {      \
        EMULOG(EMULATOR_LOG_WARNING, fmt, ##__VA_ARGS__) \
    }
#define derror(fmt, ...)                               \
    if (EMULATOR_LOG_ERROR >= getMinLogLevel()) {      \
        EMULOG(EMULATOR_LOG_ERROR, fmt, ##__VA_ARGS__) \
    }
#define dfatal(fmt, ...) EMULOG(EMULATOR_LOG_FATAL, fmt, ##__VA_ARGS__)

#ifdef __cplusplus
}
#endif