2022-05-30 03:04:26 +00:00
|
|
|
|
// this file is include huagao logging tools
|
|
|
|
|
//
|
|
|
|
|
// created: 2022-02-09
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include "../../sdk/hginclude/huagaoxxx_warraper_ex.h"
|
2023-01-19 04:13:41 +00:00
|
|
|
|
#include "lang/app_language.h"
|
2022-07-18 08:56:03 +00:00
|
|
|
|
#if defined(WIN32) || defined(_WIN64)
|
2022-05-30 03:04:26 +00:00
|
|
|
|
#define bzero(a, l) memset(a, 0, l)
|
2022-06-01 03:04:10 +00:00
|
|
|
|
#define PATH_SEPARATOR "\\"
|
2022-06-01 08:11:51 +00:00
|
|
|
|
#define DLL_EXTESION ".dll"
|
2022-09-23 02:26:04 +00:00
|
|
|
|
#define STRICMP stricmp
|
2022-06-01 03:04:10 +00:00
|
|
|
|
#else
|
2022-09-23 02:26:04 +00:00
|
|
|
|
#include <string.h>
|
2022-06-01 03:04:10 +00:00
|
|
|
|
#define PATH_SEPARATOR "/"
|
2022-06-01 08:11:51 +00:00
|
|
|
|
#define DLL_EXTESION ".so"
|
2022-09-23 02:26:04 +00:00
|
|
|
|
#define STRICMP strcasecmp
|
2022-05-30 03:04:26 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2023-01-16 09:26:07 +00:00
|
|
|
|
//#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
|
2022-05-30 03:04:26 +00:00
|
|
|
|
|
|
|
|
|
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);
|
2022-05-30 09:36:42 +00:00
|
|
|
|
std::string get_module_full_path(const char* module_part_name);
|
2022-06-01 03:04:10 +00:00
|
|
|
|
std::string get_scanner_path(void);
|
2022-06-06 04:03:24 +00:00
|
|
|
|
std::string local_data_path(void);
|
2022-06-08 01:31:35 +00:00
|
|
|
|
std::string temporary_path(void);
|
2022-07-20 06:57:26 +00:00
|
|
|
|
std::string log_file_path(void);
|
2022-12-14 06:18:17 +00:00
|
|
|
|
std::string get_scanimage_ver();
|
2023-05-13 08:26:43 +00:00
|
|
|
|
void clear_log(void);
|
2022-11-24 08:57:31 +00:00
|
|
|
|
float GetMemoryUsage(int pid);
|
|
|
|
|
float GetAppMemoryUsage();
|
2023-01-18 10:08:47 +00:00
|
|
|
|
const char* lang_load(uint32_t id);
|
2022-06-16 08:03:55 +00:00
|
|
|
|
unsigned int get_page_size(unsigned int* map_unit = nullptr);
|
2022-05-30 03:04:26 +00:00
|
|
|
|
unsigned long long available_memory(void);
|
2022-05-30 09:36:42 +00:00
|
|
|
|
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);
|
2022-05-30 03:04:26 +00:00
|
|
|
|
|
|
|
|
|
// 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);
|
2022-06-01 03:04:10 +00:00
|
|
|
|
void unint(void);
|
2022-05-30 03:04:26 +00:00
|
|
|
|
|
|
|
|
|
void log(int level, const char* info);
|
|
|
|
|
bool is_log_level_enabled(int level);
|
|
|
|
|
void log(const char* info);
|
|
|
|
|
}
|
|
|
|
|
#ifdef EXPORT_AS_C
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|