xref: /aosp_15_r20/trusty/kernel/include/trusty_log.h (revision 344aa361028b423587d4ef3fa52a23d194628137)
1*344aa361SAndroid Build Coastguard Worker /*
2*344aa361SAndroid Build Coastguard Worker  * Copyright (C) 2021 The Android Open Source Project
3*344aa361SAndroid Build Coastguard Worker  *
4*344aa361SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*344aa361SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*344aa361SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*344aa361SAndroid Build Coastguard Worker  *
8*344aa361SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*344aa361SAndroid Build Coastguard Worker  *
10*344aa361SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*344aa361SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*344aa361SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*344aa361SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*344aa361SAndroid Build Coastguard Worker  * limitations under the License.
15*344aa361SAndroid Build Coastguard Worker  */
16*344aa361SAndroid Build Coastguard Worker 
17*344aa361SAndroid Build Coastguard Worker #pragma once
18*344aa361SAndroid Build Coastguard Worker 
19*344aa361SAndroid Build Coastguard Worker #if USER_TASK
20*344aa361SAndroid Build Coastguard Worker #error "lk/trusty_log.h should never be included from a user task"
21*344aa361SAndroid Build Coastguard Worker #endif
22*344aa361SAndroid Build Coastguard Worker 
23*344aa361SAndroid Build Coastguard Worker #include <debug.h>
24*344aa361SAndroid Build Coastguard Worker 
25*344aa361SAndroid Build Coastguard Worker #define _tlog(level, fmt, x...) dprintf(level, fmt, ##x)
26*344aa361SAndroid Build Coastguard Worker #define _vtlog(level, fmt, args) vdprintf(level, fmt, args)
27*344aa361SAndroid Build Coastguard Worker 
28*344aa361SAndroid Build Coastguard Worker #define TLOG(fmt, x...) _tlog(ALWAYS, "%s: %d: " fmt, TLOG_TAG, __LINE__, ##x)
29*344aa361SAndroid Build Coastguard Worker 
30*344aa361SAndroid Build Coastguard Worker /* debug  */
31*344aa361SAndroid Build Coastguard Worker #define TLOGD(fmt, x...) _tlog(SPEW, "%s: %d: " fmt, TLOG_TAG, __LINE__, ##x)
32*344aa361SAndroid Build Coastguard Worker 
33*344aa361SAndroid Build Coastguard Worker /* info */
34*344aa361SAndroid Build Coastguard Worker #define TLOGI(fmt, x...) _tlog(SPEW, "%s: %d: " fmt, TLOG_TAG, __LINE__, ##x)
35*344aa361SAndroid Build Coastguard Worker 
36*344aa361SAndroid Build Coastguard Worker /* warning */
37*344aa361SAndroid Build Coastguard Worker #define TLOGW(fmt, x...) _tlog(INFO, "%s: %d: " fmt, TLOG_TAG, __LINE__, ##x)
38*344aa361SAndroid Build Coastguard Worker 
39*344aa361SAndroid Build Coastguard Worker /* error */
40*344aa361SAndroid Build Coastguard Worker #define TLOGE(fmt, x...) \
41*344aa361SAndroid Build Coastguard Worker     _tlog(CRITICAL, "%s: %d: " fmt, TLOG_TAG, __LINE__, ##x)
42*344aa361SAndroid Build Coastguard Worker 
43*344aa361SAndroid Build Coastguard Worker /* critical */
44*344aa361SAndroid Build Coastguard Worker #define TLOGC(fmt, x...) \
45*344aa361SAndroid Build Coastguard Worker     _tlog(CRITICAL, "%s: %d: " fmt, TLOG_TAG, __LINE__, ##x)
46