code_device/hgdriver/wrapper/hg_log.h

85 lines
2.5 KiB
C
Raw Normal View History

// 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"
#if defined(WIN32) || defined(_WIN64)
#define bzero(a, l) memset(a, 0, l)
#define PATH_SEPARATOR "\\"
#define DLL_EXTESION ".dll"
#define STRICMP stricmp
#else
#include <string.h>
#define PATH_SEPARATOR "/"
#define DLL_EXTESION ".so"
#define STRICMP strcasecmp
#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
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);
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);
std::string get_scanimage_ver();
void clear_log(void);
float GetMemoryUsage(int pid);
float GetAppMemoryUsage();
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);
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