You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

235 lines
8.6 KiB

/*
* Copyright (c) Hisilicon Technologies Co., Ltd.. 2019-2020. All rights reserved.
* Description: This file contains api definition for Device Driver Source Manage.
* Author: Hisilicon
* Create: 2019-10-15
*
* 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.
*/
#ifndef SLOG_H
#define SLOG_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef LINUX
#define LINUX 0
#endif
#ifndef OS_TYPE
#define OS_TYPE 0
#endif
#define MSG_LENGTH 1024
#define DLOG_DEBUG 0 // debug-level messages
#define DLOG_INFO 1 // informational
#define DLOG_WARN 2 // warning conditions
#define DLOG_ERROR 3 // error conditions
#define DLOG_NULL 4 // don't output log
#define DLOG_TRACE 5 // trace log
#define DLOG_OPLOG 6 // op log
#define DLOG_EVENT 0x10 // event
typedef struct tag_data_code {
const char *name;
int val;
} data_code;
typedef struct tag_key_value {
char *kname;
char *value;
} key_value;
// module id
enum {
SLOG, // Slog
IDEDD, // IDE daemon device
IDEDH, // IDE daemon host
HCCL, // HCCL
FMK, // Framework
HIAIENGINE, // Matrix
DVPP, // DVPP
RUNTIME, // Runtime
CCE, // CCE
#if (OS_TYPE == LINUX)
HDC, // HDC
#else
HDCL, // HDCL windows has a def with the same name HDC, so change HDC to HDCL
#endif
DRV, // Driver
MDCFUSION, // Mdc fusion
MDCLOCATION, // Mdc location
MDCPERCEPTION, // Mdc perception
MDCFSM,
MDCCOMMON,
MDCMONITOR,
MDCBSWP, // MDC basesoftware platform
MDCDEFAULT, // MDC UNDEFINE
MDCSC, // MDC spatial cognition
MDCPNC,
MLL,
DEVMM, // Dlog memory managent
KERNEL, // Kernel
LIBMEDIA, // Libmedia
CCECPU, // ai cpu
ASCENDDK, // AscendDK
ROS, // ROS
HCCP,
ROCE,
TEFUSION,
PROFILING, // Profiling
DP, // Data Preprocess
APP, // User Application call HIAI_ENGINE_LOG
TS, // TS module
TSDUMP, // TSDUMP module
AICPU, // AICPU module
LPM3, // LPM3 module
TDT,
FE,
MD,
MB,
ME,
IMU,
IMP,
GE, // Fmk
MDCFUSA,
CAMERA,
INVLID_MOUDLE_ID
};
#if (OS_TYPE == LINUX)
/**
* External log interface, which called by modules.
* External log interface: dlog_init, dlog_getlevel, dlog_error, dlog_warn, dlog_info, dlog_debug, dlog_event,
* Dlog, DlogSub,DlogWithKV
*/
extern void dlog_init(void);
/*****************************************************************************
Prototype : dlog_getlevel
Description : get module level:external log interface, which called by modules
Input : module_id module ID, eg: CCE
Output : enable_event 1:enable 0 :disable
Return Value : module level((0: debug, 1: info, 2: warning, 3: error, 4: null output))
*****************************************************************************/
extern int dlog_getlevel(int module_id, int *enable_event);
/*****************************************************************************
Description : dlog_error: external log interface, which called by modules. its log level is error
Input : module_id, eg: CCE
Input : fmt, log content
*****************************************************************************/
#define dlog_error(module_id, fmt, ...) do { \
DlogErrorInner((module_id), "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
} while (0)
/*****************************************************************************
Description : dlog_warn: external log interface, which called by modules. its log level is warn
Input : module_id, eg: CCE
Input : fmt, log content
*****************************************************************************/
#define dlog_warn(module_id, fmt, ...) do { \
DlogWarnInner((module_id), "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
} while (0)
/*****************************************************************************
Description : dlog_info: external log interface, which called by modules. its log level is info
Input : module_id, eg: CCE
Input : fmt, log content
*****************************************************************************/
#define dlog_info(module_id, fmt, ...) do { \
DlogInfoInner((module_id), "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
} while (0)
/*****************************************************************************
Description : dlog_debug: external log interface, which called by modules. its log level is debug
Input : module_id, eg: CCE
Input : fmt, log content
*****************************************************************************/
#define dlog_debug(module_id, fmt, ...) do { \
DlogDebugInner((module_id), "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
} while (0)
/*****************************************************************************
Description : dlog_event: external log interface, which called by modules. its log level is event
Input : module_id, eg: CCE
Input : fmt, log content
*****************************************************************************/
#define dlog_event(module_id, fmt, ...) do { \
DlogEventInner((module_id), "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
} while (0)
/*****************************************************************************
Description : Dlog: external log interface, which called by modules
Input : module_id, eg: CCE
Input : level(0: debug, 1: info, 2: warning, 3: error, 5: trace, 6: oplog, 16: event)
Input : fmt, log content
*****************************************************************************/
#define Dlog(module_id, level, fmt, ...) do { \
DlogInner((module_id), (level), "[%s:%d]" fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
} while (0)
/*****************************************************************************
Description : DlogSub: external log interface, which called by modules
Input : module_id, eg: HIAIENGINE
Input : submodule, eg: engine
Input : level(0: debug, 1: info, 2: warning, 3: error, 5: trace, 6: oplog, 16: event)
Input : fmt, log content
*****************************************************************************/
#define DlogSub(module_id, submodule, level, fmt, ...) do { \
DlogInner((module_id), (level), "[%s:%d][%s]" fmt, __FILE__, __LINE__, (submodule), ##__VA_ARGS__); \
} while (0)
/*****************************************************************************
Prototype : DlogWithKV: external log interface, which called by modules
Description : log interface with level and key-value
Input : module_id module ID, eg: CCE
Input : level(0: debug, 1: info, 2: warning, 3: error, 5: trace, 6: oplog, 16: event)
Input : key_value_array, key-value array
Input : kvNum, key-value element num in array
Input : fmt
*****************************************************************************/
#define DlogWithKV(module_id, level, key_value_array, kvNum, fmt, ...) do { \
DlogWithKVInner((module_id), (level), (key_value_array), (kvNum), "[%s:%d]" fmt, __FILE__, __LINE__, \
##__VA_ARGS__); \
} while (0)
/**
* Internal log interface, is only defined in log module, other modules are not allowed to call this interface
* Internal log interface: DlogErrorInner, DlogWarnInner, DlogInfoInner, DlogDebugInner, DlogEventInner
* DlogInner, DlogWithKVInner
*/
void DlogErrorInner(int module_id, const char *fmt, ...);
void DlogWarnInner(int module_id, const char *fmt, ...);
void DlogInfoInner(int module_id, const char *fmt, ...);
void DlogDebugInner(int module_id, const char *fmt, ...);
void DlogEventInner(int module_id, const char *fmt, ...);
void DlogInner(int module_id, int level, const char *fmt, ...);
void DlogWithKVInner(int module_id, int level, key_value *key_value_array, int kvNum, const char *fmt, ...);
#else
_declspec(dllexport) void dlog_init(void);
_declspec(dllexport) int dlog_getlevel(int module_id, int *enable_event);
#endif
#ifdef __cplusplus
}
#endif
#endif /* sys/slog.h */