77 lines
2.2 KiB
C++
77 lines
2.2 KiB
C++
// this file is include huagao logging tools
|
|
//
|
|
// created: 2022-02-09
|
|
//
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include "../../sdk/hginclude/huagaoxxx_warraper_ex.h"
|
|
|
|
#if defined(WIN32) || defined(_WIN64)
|
|
#define bzero(a, l) memset(a, 0, l)
|
|
#define PATH_SEPARATOR "\\"
|
|
#define DLL_EXTESION ".dll"
|
|
#else
|
|
#define PATH_SEPARATOR "/"
|
|
#define DLL_EXTESION ".so"
|
|
#endif
|
|
|
|
#ifdef OEM_HANWANG
|
|
#define hg_log hw_log
|
|
#define hg_log_type hw_log_type
|
|
#elif defined(OEM_LISICHENG)
|
|
#define hg_log lsc_log
|
|
#define hg_log_type lsc_log_type
|
|
#endif
|
|
|
|
enum hg_log_type
|
|
{
|
|
LOG_TYPE_NONE = 0, // no logging
|
|
LOG_TYPE_CONSOLE, // print to console
|
|
LOG_TYPE_FILE, // write log into file
|
|
LOG_TYPE_CALLBACK, // invoke callback log_callback
|
|
};
|
|
|
|
typedef void (*log_callback)(int, const char* info);
|
|
|
|
#ifdef EXPORT_AS_C
|
|
extern "C"
|
|
{
|
|
#endif
|
|
namespace hg_log
|
|
{
|
|
std::string format_ptr(void* ptr);
|
|
std::string format_current_thread_id(void);
|
|
std::string current_time(void);
|
|
std::string format_size(unsigned long size);
|
|
std::string u2utf8(const wchar_t* u);
|
|
std::string pe_path(std::string* name = nullptr);
|
|
std::string get_module_full_path(const char* module_part_name);
|
|
std::string get_scanner_path(void);
|
|
std::string local_data_path(void);
|
|
std::string temporary_path(void);
|
|
std::string log_file_path(void);
|
|
unsigned int get_page_size(unsigned int* map_unit = nullptr);
|
|
unsigned long long available_memory(void);
|
|
void str_tolower(std::string& str);
|
|
bool create_folder(const char* fodler);
|
|
|
|
std::string ini_get(const char* app, const char* key);
|
|
void ini_set(const char* app, const char* key, const char* val);
|
|
|
|
// Function: initialize the logging type and level
|
|
//
|
|
// Return: 0 - success, or -1 in LOG_TYPE_FILE and log_file cannot be created
|
|
int init(void);
|
|
void unint(void);
|
|
|
|
void log(int level, const char* info);
|
|
bool is_log_level_enabled(int level);
|
|
void log(const char* info);
|
|
}
|
|
#ifdef EXPORT_AS_C
|
|
}
|
|
#endif
|
|
|