1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <android-base/logging.h>
20 
21 #define FSTAB_TAG "[libfstab] "
22 
23 /* The CHECK() in logging.h will use program invocation name as the tag.
24  * Thus, the log will have prefix "init: " when libfs_mgr is statically
25  * linked in the init process. This might be opaque when debugging.
26  * Append a library name tag at the end of the abort message to aid debugging.
27  */
28 #define FSTAB_CHECK(x) CHECK(x) << "in " << FSTAB_TAG
29 
30 // Logs a message to kernel
31 #define LINFO LOG(INFO) << FSTAB_TAG
32 #define LWARNING LOG(WARNING) << FSTAB_TAG
33 #define LERROR LOG(ERROR) << FSTAB_TAG
34 #define LFATAL LOG(FATAL) << FSTAB_TAG
35 
36 // Logs a message with strerror(errno) at the end
37 #define PINFO PLOG(INFO) << FSTAB_TAG
38 #define PWARNING PLOG(WARNING) << FSTAB_TAG
39 #define PERROR PLOG(ERROR) << FSTAB_TAG
40 #define PFATAL PLOG(FATAL) << FSTAB_TAG
41