TuyaOS
log_seq.h
浏览该文件的文档.
1
11#ifndef __LOG_SEQ_H
12#define __LOG_SEQ_H
13
14#include "tuya_cloud_types.h"
15
16#include "tuya_list.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22
23#define STR_DATA_MAX_LENGTH 64
24
25typedef BYTE_T LS_DATA_TP_T; // log sequence data type
26#define LDT_NULL 0
27#define LDT_DEC 1
28#define LDT_HEX 2
29#define LDT_TIMESTAMP 3
30#define LDT_STRING 4
31
32
36typedef union {
37 INT_T dec_data;
38 UINT_T hex_data;
39 TIME_T tm_data;
40 CHAR_T *str_data;
42
46typedef struct {
48 BYTE_T id;
50 LS_DATA_TP_T type;
54 struct tuya_list_head node;
55} LS_DATA_S;
56
57typedef BYTE_T LS_STAT_T;
58#define LSS_INIT 0
59#define LSS_RECORDING 1
60#define LSS_LOCKED 2 // LOG_SEQ_T set locked status when record the error log sequence
61
62// Calling when record the error log sequence
63typedef int (*LOG_SEQ_UPLOAD_CB)(const char *p_log);
64
65#define LS_DELIMITER " | "
66
67int log_seq_insert_log(const char *ls_name, BYTE_T id, LS_DATA_TP_T type, VOID_T* data);
68int log_seq_insert_error_log(const char *ls_name, BYTE_T id, LS_DATA_TP_T type, VOID_T* data);
69int log_seq_insert_report_log(const char *ls_name, BYTE_T id, LS_DATA_TP_T type, VOID_T* data);
70
71#define INSERT_LOG_SEQ_NULL(seq) log_seq_insert_log(LOGSEQ_OBJ, seq, LDT_NULL, NULL)
72#define INSERT_LOG_SEQ_DEC(seq,dec) log_seq_insert_log(LOGSEQ_OBJ, seq, LDT_DEC, (VOID_T*)(intptr_t)dec)
73#define INSERT_LOG_SEQ_HEX(seq,hex) log_seq_insert_log(LOGSEQ_OBJ, seq, LDT_HEX, (VOID_T*)(uintptr_t)hex)
74#define INSERT_LOG_SEQ_TM(seq,tm) log_seq_insert_log(LOGSEQ_OBJ, seq, LDT_TIMESTAMP, (VOID_T*)tm)
75//string max length is STR_DATA_MAX_LENGTH
76#define INSERT_LOG_SEQ_STR(seq,str) log_seq_insert_log(LOGSEQ_OBJ, seq, LDT_STRING, (VOID_T*)str)
77#define INSERT_ERROR_LOG_SEQ_NULL(seq) log_seq_insert_error_log(LOGSEQ_OBJ, seq, LDT_NULL, NULL)
78#define INSERT_ERROR_LOG_SEQ_DEC(seq,dec) log_seq_insert_error_log(LOGSEQ_OBJ, seq, LDT_DEC, (VOID_T*)(intptr_t)dec)
79#define INSERT_ERROR_LOG_SEQ_HEX(seq,hex) log_seq_insert_error_log(LOGSEQ_OBJ, seq, LDT_HEX, (VOID_T*)(uintptr_t)hex)
80#define INSERT_ERROR_LOG_SEQ_TM(seq,tm) log_seq_insert_error_log(LOGSEQ_OBJ, seq, LDT_TIMESTAMP, (VOID_T*)tm)
81//string max length is STR_DATA_MAX_LENGTH
82#define INSERT_ERROR_LOG_SEQ_STR(seq,str) log_seq_insert_error_log(LOGSEQ_OBJ, seq, LDT_STRING, (VOID_T*)str)
83#define INSERT_REPORT_LOG_SEQ_NULL(seq) log_seq_insert_report_log(LOGSEQ_OBJ, seq, LDT_NULL, NULL)
84#define INSERT_REPORT_LOG_SEQ_DEC(seq,dec) log_seq_insert_report_log(LOGSEQ_OBJ, seq, LDT_DEC, (VOID_T*)(intptr_t)dec)
85#define INSERT_REPORT_LOG_SEQ_HEX(seq,hex) log_seq_insert_report_log(LOGSEQ_OBJ, seq, LDT_HEX, (VOID_T*)(uintptr_t)hex)
86#define INSERT_REPORT_LOG_SEQ_TM(seq,tm) log_seq_insert_report_log(LOGSEQ_OBJ, seq, LDT_TIMESTAMP, (VOID_T*)tm)
87//string max length is STR_DATA_MAX_LENGTH
88#define INSERT_REPORT_LOG_SEQ_STR(seq,str) log_seq_insert_report_log(LOGSEQ_OBJ, seq, LDT_STRING, (VOID_T*)str)
89
90
100int log_seq_init(const char *log_seq_path);
101
111int log_seq_set_enable(bool_t enable);
112
122int log_seq_set_force_report(bool_t enable);
123
133int log_seq_set_depth(const unsigned int depth);
134
144int log_seq_clean(int is_force_clean_all);
145
156
166int log_seq_upload_custom_log(const char *p_log);
167
178int log_seq_get_netcfg_log(char **log_buff, int *log_len);
179
180
181
182#ifdef __cplusplus
183}
184#endif
185#endif
186
int log_seq_set_force_report(bool_t enable)
enable or disable force report repeat
int log_seq_set_enable(bool_t enable)
enable or disable log sequence.
int log_seq_clean(int is_force_clean_all)
reset log sequence, clean all log sequence, this is used when device reset.
int log_seq_get_netcfg_log(char **log_buff, int *log_len)
get network configure log sequence.
int log_seq_set_depth(const unsigned int depth)
set log sequence depth.
int log_seq_force_sync(void)
force synchronization of log sequence .
int log_seq_upload_custom_log(const char *p_log)
upload customer log sequence .
int log_seq_init(const char *log_seq_path)
initialize of log sequence.
data structure of log sequence
Definition: log_seq.h:46
LS_DATA_TP_T type
Definition: log_seq.h:50
BYTE_T id
Definition: log_seq.h:48
LOG_DA_TP_U data
Definition: log_seq.h:52
data storage structure of log sequence
Definition: log_seq.h:36