1/*
2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef OHOS_CAMERA_LOG_H
17#define OHOS_CAMERA_LOG_H
18
19#include <stdio.h>
20
21#include "hilog/log.h"
22
23#undef LOG_DOMAIN
24#undef LOG_TAG
25#define LOG_DOMAIN 0xD002513
26#define LOG_TAG "METADATA"
27
28#define FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)
29
30#ifndef OHOS_DEBUG
31#define DECORATOR_HILOG(op, fmt, args...) \
32    do {                                  \
33        op(LOG_CORE, fmt, ##args);        \
34    } while (0)
35#else
36#define DECORATOR_HILOG(op, fmt, args...)                                                \
37    do {                                                                                 \
38        op(LOG_CORE, "{%s()-%s:%d} " fmt, __FUNCTION__, FILENAME, __LINE__, ##args); \
39    } while (0)
40#endif
41
42#ifdef DEBUG_BUILD
43#define METADATA_DEBUG_LOG(fmt, ...) DECORATOR_HILOG(HILOG_DEBUG, fmt, ##__VA_ARGS__)
44#else
45#define METADATA_DEBUG_LOG(fmt, ...)
46#endif
47
48#define METADATA_ERR_LOG(fmt, ...) DECORATOR_HILOG(HILOG_ERROR, fmt, ##__VA_ARGS__)
49#define METADATA_WARNING_LOG(fmt, ...) DECORATOR_HILOG(HILOG_WARN, fmt, ##__VA_ARGS__)
50#define METADATA_INFO_LOG(fmt, ...) DECORATOR_HILOG(HILOG_INFO, fmt, ##__VA_ARGS__)
51#define METADATA_FATAL_LOG(fmt, ...) DECORATOR_HILOG(HILOG_FATAL, fmt, ##__VA_ARGS__)
52
53#define METADATA_OK 0
54#define METADATA_INVALID_PARAM (-1)
55#define METADATA_INIT_FAIL (-2)
56#define METADATA_ERR (-3)
57#define METADATA_PERMISSION_DENIED (-4)
58
59#endif // OHOS_CAMERA_LOG_H
60