/*
 * @Author: zchuo zhengchen.huo@lnxall.com
 * @Date: 2025-04-21 17:31:56
 * @LastEditors: zchuo zhengchen.huo@lnxall.com
 * @LastEditTime: 2025-04-24 15:41:39
 * @FilePath: /proto_forward/src/log_module/log_upper_data.h
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#ifndef LOG_UPPER_DATA_H__
#define LOG_UPPER_DATA_H__
#include <time.h>
#include "lnxall_buffer.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <pthread.h>
#include "lnxall_list.h"
#include "open62541.h"

#define UD_LOG_FILE_LEN 20

// enum __UD_LOG_BIT
// {
//     UD_LOG_BIT_ANTIU = 0x01,    // 防逆流log
//     UD_LOG_BIT_MICRO = 0x02,    // 微网log
// };

extern UA_NodeId UD_LOG_UA_NODE;
extern long ud_log_Level;
struct UD_log;
typedef int (*SET_EN_BACK)(struct UD_log *self);
struct UD_log
{
    const char *file_name;
    pthread_mutex_t mutex;
    struct lnxall_buff prt_buf;
    struct list_head list; 
    int en;
    SET_EN_BACK set_en_back;
};

int UD_log_init();
struct UD_log *UD_log_creat(const char *file_name, SET_EN_BACK set_en_back);
int UD_log_sprintf(struct UD_log *self, const char *p, ...);
int clear_UD_log(struct UD_log *self);
int fwrite_flush_UD_log(struct UD_log *self);
int UD_log_free(struct UD_log *self);
int UD_log_update_en();

#endif