mirror of https://gitee.com/openkylin/docs.git
更新翻译
Signed-off-by: jlspcdd1227dd <12046126+jlspcdd1227dd@user.noreply.gitee.com>
This commit is contained in:
parent
38702b71e9
commit
e3a136e20f
|
@ -2583,62 +2583,62 @@ target_link_libraries(kylog-testpressure kylog)
|
|||
> output log
|
||||
|
||||
|
||||
| 类型 | statement |
|
||||
| type | statement |
|
||||
|---------------|---------------------------------|
|
||||
| 输出debug级别日志 | #define klog_debug(fmt , ...) |
|
||||
| 输出info级别日志 | #define klog_info(fmt , ...) |
|
||||
| 输出notice级别日志 | #define klog_notice(fmt , ...) |
|
||||
| 输出warning级别日志 | #define klog_warning(fmt , ...) |
|
||||
| 输出error级别日志 | #define klog_err(fmt , ...) |
|
||||
| 输出crit级别日志 | #define klog_crit(fmt , ...) |
|
||||
| 输出alert级别日志 | #define klog_alert(fmt , ...) |
|
||||
| 输出emerg级别日志 | #define klog_emerg(fmt , ...) |
|
||||
| Output debug level log | #define klog_debug(fmt , ...) |
|
||||
| Output info level log | #define klog_info(fmt , ...) |
|
||||
| Output notice level log | #define klog_notice(fmt , ...) |
|
||||
| Output warning level log | #define klog_warning(fmt , ...) |
|
||||
| Output error level log | #define klog_err(fmt , ...) |
|
||||
| Output crit level log | #define klog_crit(fmt , ...) |
|
||||
| Output alert level log | #define klog_alert(fmt , ...) |
|
||||
| Output emerg level log | #define klog_emerg(fmt , ...) |
|
||||
|
||||
|
||||
|
||||
> 初始化日志记录
|
||||
> Initialize logging
|
||||
|
||||
| submodule | Programming language | statement | describe |
|
||||
|-----|------|-----------------------------------|----------------------------------|
|
||||
| 日志 | C | extern int | kdk_logger_init(const char *ini) | 初始化日志记录,也可以不调用该函数直接使用上方日志记录的宏,若以此方式运行,则程序会使用默认的日志配置文件 |
|
||||
| log | C | extern int | kdk_logger_init(const char *ini) | Initialize the log record, or directly use the above log record macro without calling this function, if run in this way, the program will use the default log configuration file |
|
||||
| | | Parameter Description | Return value description | |
|
||||
| | | ini:日志配置文件路径,若传入NULL则会使用默认的日志配置文件 | int,0表示成功,非0表示失败 |
|
||||
| | | ini:Log configuration file path, if NULL is passed in, the default log configuration file will be used | int,0 means success, non-zero means failure |
|
||||
|
||||
|
||||
> 缓存区日志写入
|
||||
> Buffer log write
|
||||
|
||||
| submodule | Programming language | statement | describe |
|
||||
|-----|------|-------------|--------------------------------|
|
||||
| 日志 | C | extern void | kdk_logger_flush() DESTRUCTOR; | 在异步写入的方式下,可以调用该函数手动将缓存区中的日志写入文件中 |
|
||||
| log | C | extern void | kdk_logger_flush() DESTRUCTOR; | In the asynchronous writing mode, you can call this function to manually write the logs in the buffer to the file |
|
||||
| | | Parameter Description | Return value description | |
|
||||
| | | 无 | 无 |
|
||||
|
||||
|
||||
|
||||
> 设置日志存储目录
|
||||
> Set the log storage directory
|
||||
|
||||
| submodule | Programming language | statement | describe |
|
||||
|-----|------|-------------------------------------------------|---------------------------------------------------------|
|
||||
| 日志 | C | extern int kdk_logger_setdir(const char* dpath) | 设置日志的存储目录,若不设置,非root程序会被记录在~/.log下,root程序会被记录在/var/log下 |
|
||||
| log | C | extern int kdk_logger_setdir(const char* dpath) | Set the log storage directory, if not set, non-root programs will be recorded in ~/.log, root programs will be recorded in /var/log |
|
||||
| | | Parameter Description | Return value description | |
|
||||
| | | dpath:日志存储路径 | int | 成功返回0,失败返回-1 |
|
||||
| | | dpath: log storage path | int | Returns 0 on success, -1 on failure |
|
||||
|
||||
|
||||
|
||||
> 设置日志输出自动换行
|
||||
> Set log output to wrap automatically
|
||||
|
||||
|
||||
| submodule | Programming language | statement | describe |
|
||||
|-----|------|---------------------------------------------------|------------|
|
||||
| 日志 | C | extern void kdk_logger_set_autowrap(int autowarp) | 设置日志输出自动换行 |
|
||||
| log | C | extern void kdk_logger_set_autowrap(int autowarp) | Set log output to wrap automatically |
|
||||
| | | Parameter Description | Return value description | |
|
||||
| | | autowarp:1表示启用启动换行,0表示禁止自动换行 | 无 |
|
||||
| | | autowarp:1 means start line wrapping is enabled, 0 means automatic line wrapping is disabled | 无 |
|
||||
|
||||
|
||||
|
||||
## **5.2** 定时器
|
||||
## **5.2** Timer
|
||||
>
|
||||
> C 语言定时器模块,给 C/C++程序提供定时器功能接口。
|
||||
> C language timer module, providing timer function interface for C/C++ program.
|
||||
|
||||
|
||||
```
|
||||
|
@ -2646,7 +2646,7 @@ $ sudo apt-get install libkysdk-timer libkysdk-timer-dev
|
|||
```
|
||||
|
||||
|
||||
> (1)CMakeLists.txt 构建项目
|
||||
> (1)CMakeLists.txt build project
|
||||
>
|
||||
```
|
||||
aux_source_directory(. SOURCESCODE)
|
||||
|
@ -2656,82 +2656,81 @@ target_link_libraries(kytimer pthread)
|
|||
target_link_libraries(test-kytimer kytimer)
|
||||
```
|
||||
|
||||
> (2)调用定时器模块,需要添加头文件:
|
||||
> (2)To call the timer module, you need to add a header file:
|
||||
>
|
||||
```
|
||||
#include "kysdk/kysdk-base/libkytimer.h"
|
||||
```
|
||||
>
|
||||
> 初始化定时器
|
||||
> Initialize timer
|
||||
|
||||
| submodule | Programming language | statement | describe |
|
||||
|-----|------|----------------------|------------------|
|
||||
| 定时器 | C | int kdk_timer_init() | 初始化定时器核心组件 |
|
||||
| timer | C | int kdk_timer_init() | Initialize the timer core component |
|
||||
| | | Parameter Description | Return value description | |
|
||||
| | | 无 | int,0表示成功,非0表示失败 |
|
||||
| | | 无 | int,0 means success, non-zero means failure |
|
||||
|
||||
|
||||
> 启动定时器
|
||||
> start timer
|
||||
|
||||
|
||||
| submodule | Programming language | statement | describe |
|
||||
|-----|------|----------------------|------------------|
|
||||
| 定时器 | C | size_t | kdk_timer_start(unsigned int intervalms, time_handler callback, KTimerAttribute attr, KTimerType type, void* userdata, int freeOnDelete) |
|
||||
| timer | C | size_t | kdk_timer_start(unsigned int intervalms, time_handler callback, KTimerAttribute attr, KTimerType type, void* userdata, int freeOnDelete) |
|
||||
| | | Parameter Description | Return value description |
|
||||
| | | intervalms:定时器时间,以毫秒为单位 | size_t定时器的ID |
|
||||
| | | callback:定时器到期后触发的回调函数指针 | |
|
||||
| | | attr:定时器属性,KTIMER_SINGLESHOT表示一次性定时器;KTIMER_PERIODIC表示周期性定时器;KTIMER_NEVER表示不会被触发的定时器 | |
|
||||
| | | type:定时器类型,KTIMER_ABSOLUTE表示绝对时间定时器,修改系统时间不会影响定时器的时间;KTIMER_RELATIVE表示相对时间定时器,修改系统时间会影响定时器时间 | |
|
||||
| | | userdata:指向用户数据的指针 | |
|
||||
| | | freeOnDelete: [未启用] | |
|
||||
| | | intervalms:timer time in milliseconds | The ID of the size_t timer |
|
||||
| | | callback:The callback function pointer triggered after the timer expires | |
|
||||
| | | attr:Timer attribute, KTIMER_SINGLESHOT indicates a one-time timer; KTIMER_PERIODIC indicates a periodic timer; KTIMER_NEVER indicates a timer that will not be triggered | |
|
||||
| | | type:Timer type, KTIMER_ABSOLUTE indicates an absolute time timer, modifying the system time will not affect the timer time; KTIMER_RELATIVE indicates a relative time timer, modifying the system time will affect the timer time | |
|
||||
| | | userdata:pointer to user data | |
|
||||
| | | freeOnDelete: [Not Enabled] | |
|
||||
|
||||
|
||||
|
||||
> 停止给定的定时器
|
||||
> stop the given timer
|
||||
|
||||
|
||||
| submodule | Programming language | statement | describe |
|
||||
|-----|------|-------------------------------------|----------|
|
||||
| 定时器 | C | void kdk_timer_stop(size_t timerfd) | 停止给定的定时器 |
|
||||
| timer | C | void kdk_timer_stop(size_t timerfd) | stop the given timer |
|
||||
| | | Parameter Description | Return value description | |
|
||||
| | | timerfd:由kdk_timer_start:返回的定时器ID | 无 |
|
||||
| | | timerfd:Timer ID returned by kdk_timer_start: | 无 |
|
||||
|
||||
|
||||
|
||||
> 销毁定时器
|
||||
> destroy timer
|
||||
|
||||
|
||||
| submodule | Programming language | statement | describe |
|
||||
|-----|------|--------------------------|-------|
|
||||
| 定时器 | C | void kdk_timer_destroy() | 销毁定时器 |
|
||||
| timer | C | void kdk_timer_destroy() | destroy timer |
|
||||
| | | Parameter Description | Return value description | |
|
||||
| | | 无 | 无 |
|
||||
|
||||
|
||||
|
||||
> 重置定时器
|
||||
> reset timer
|
||||
|
||||
|
||||
| submodule | Programming language | statement | describe |
|
||||
|-----|------|----------------------------------------------------------------|-------|
|
||||
| 定时器 | C | void kdk_timer_reset(size_t timerfd , unsigned int intervalms) | 重置定时器 |
|
||||
| timer | C | void kdk_timer_reset(size_t timerfd , unsigned int intervalms) | reset timer |
|
||||
| | | Parameter Description | Return value description |
|
||||
| | | timerfd:由kdk_timer_start返回的定时器ID | 无 |
|
||||
| | | intervalms:需要调整的时间间隔,以ms为单位 | |
|
||||
| | | timerfd:Timer ID returned by kdk_timer_start | 无 |
|
||||
| | | intervalms:The time interval that needs to be adjusted, in ms | |
|
||||
|
||||
|
||||
|
||||
## **5.3** C 语言字符串扩展
|
||||
## **5.3** C language string extension
|
||||
>
|
||||
> 该模块封装了对字符串操作的 C 接口,包括字符串裁剪、分割、大小写转换、查找特定字符等操作。
|
||||
|
||||
> This module encapsulates the C interface for string operations, including string cropping, splitting, case conversion, and searching for specific characters.
|
||||
|
||||
```
|
||||
$ sudo apt-get install libkysdk-utils libkysdk-utils-dev
|
||||
|
||||
```
|
||||
|
||||
> (1)调用 C 语言字符串扩展模块,需要添加头文件:
|
||||
> (1)To call the C language string extension module, a header file needs to be added:
|
||||
>
|
||||
```
|
||||
#include "kysdk/kysdk-base/cstring-extension.h"
|
||||
|
|
Loading…
Reference in New Issue