mirror of
https://github.com/RubyMetric/chsrc.git
synced 2025-03-13 07:55:12 +08:00
Rename log functions
This commit is contained in:
parent
8f5423f704
commit
26181611a5
39
include/xy.h
39
include/xy.h
@ -8,7 +8,7 @@
|
||||
* Contributors : Null Nil <null@nil.com>
|
||||
* |
|
||||
* Created on : <2023-08-28>
|
||||
* Last modified : <2024-07-09>
|
||||
* Last modified : <2024-08-08>
|
||||
*
|
||||
* xy: 襄阳、咸阳
|
||||
* Corss-Platform C utilities for CLI applications in Ruby flavor
|
||||
@ -17,7 +17,7 @@
|
||||
#ifndef XY_H
|
||||
#define XY_H
|
||||
|
||||
#define _XY_Version "v0.1.3.0-2024/07/09"
|
||||
#define _XY_Version "v0.1.4.0-2024/08/08"
|
||||
#define _XY_Maintain_URL "https://gitee.com/RubyMetric/chsrc/blob/main/include/xy.h"
|
||||
|
||||
#include <assert.h>
|
||||
@ -489,16 +489,37 @@ _xy_log (int level, const char *prompt, const char *content)
|
||||
|
||||
|
||||
/**
|
||||
* remarkably 系列输出受 pip 启发,为了输出方便,使用xy.h的程序应该基于此再定义自己的 app_info_remarkbaly()
|
||||
* brkt 系列输出受 pip 启发,为了输出方便,使用 xy.h 的程序应该
|
||||
*
|
||||
* 1.若想完全自定义颜色和输出位置:
|
||||
*
|
||||
* 应基于下述 xy_log_brkt_to 定义自己的输出函数
|
||||
*
|
||||
* 2.若想自定义颜色,而保持输出到stdout:
|
||||
*
|
||||
* 应基于下述 xy_log_brkt 定义
|
||||
*
|
||||
* 3.若对log无细致要求,想要快速使用log功能:
|
||||
*
|
||||
* 应基于下述 xy_<level>_brkt 定义自己的 app_<level>_brkt(),或直接使用 xy_<level>_brkt
|
||||
*/
|
||||
#define xy_log_remarkably(prompt1,prompt2,content) _xy_log_remarkably(_XY_Log_Plain, prompt1,prompt2,content)
|
||||
#define xy_succ_remarkably(prompt1,prompt2,content) _xy_log_remarkably(_XY_Log_Success,prompt1,prompt2,content)
|
||||
#define xy_info_remarkably(prompt1,prompt2,content) _xy_log_remarkably(_XY_Log_Info, prompt1,prompt2,content)
|
||||
#define xy_warn_remarkably(prompt1,prompt2,content) _xy_log_remarkably(_XY_Log_Warn, prompt1,prompt2,content)
|
||||
#define xy_error_remarkably(prompt1,prompt2,content) _xy_log_remarkably(_XY_Log_Error, prompt1,prompt2,content)
|
||||
|
||||
static void
|
||||
_xy_log_remarkably (int level, const char *prompt1, const char *prompt2, const char *content)
|
||||
xy_log_brkt_to (const char *prompt, const char *content, FILE *stream)
|
||||
{
|
||||
char *str = xy_strjoin (4, "[", prompt, "] ", content);
|
||||
fprintf (stream, "%s\n", str);
|
||||
free (str);
|
||||
}
|
||||
|
||||
#define xy_log_brkt(prompt1,prompt2,content) _xy_log_brkt(_XY_Log_Plain, prompt1,prompt2,content)
|
||||
#define xy_succ_brkt(prompt1,prompt2,content) _xy_log_brkt(_XY_Log_Success,prompt1,prompt2,content)
|
||||
#define xy_info_brkt(prompt1,prompt2,content) _xy_log_brkt(_XY_Log_Info, prompt1,prompt2,content)
|
||||
#define xy_warn_brkt(prompt1,prompt2,content) _xy_log_brkt(_XY_Log_Warn, prompt1,prompt2,content)
|
||||
#define xy_error_brkt(prompt1,prompt2,content) _xy_log_brkt(_XY_Log_Error, prompt1,prompt2,content)
|
||||
|
||||
static void
|
||||
_xy_log_brkt (int level, const char *prompt1, const char *prompt2, const char *content)
|
||||
{
|
||||
char *str = NULL;
|
||||
|
||||
|
12
test/xy.c
12
test/xy.c
@ -5,7 +5,7 @@
|
||||
* License : MIT
|
||||
* Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
* Created on : <2023-08-30>
|
||||
* Last modified : <2024-07-09>
|
||||
* Last modified : <2024-08-08>
|
||||
*
|
||||
* 测试 xy.h
|
||||
* ------------------------------------------------------------*/
|
||||
@ -47,11 +47,11 @@ main (int argc, char const *argv[])
|
||||
xy_warn ("警告", "输出警告内容");
|
||||
xy_error ("错误", "输出错误内容");
|
||||
|
||||
xy_log_remarkably ("xy.h", "普通", "咸阳油泼面筋道十足辣子香");
|
||||
xy_succ_remarkably ("xy.h", "成功", "西安花干鸡蛋肉夹馍已出炉");
|
||||
xy_info_remarkably ("xy.h", "信息", "襄阳牛肉面搭配黄酒更美味");
|
||||
xy_warn_remarkably ("xy.h", "警告", "兰州牛肉面,而非兰州拉面");
|
||||
xy_error_remarkably ("xy.h", "错误", "西安肉丸胡辣汤里没有肉丸");
|
||||
xy_log_brkt ("xy.h", "普通", "咸阳油泼面筋道十足辣子香");
|
||||
xy_succ_brkt ("xy.h", "成功", "西安花干鸡蛋肉夹馍已出炉");
|
||||
xy_info_brkt ("xy.h", "信息", "襄阳牛肉面搭配黄酒更美味");
|
||||
xy_warn_brkt ("xy.h", "警告", "兰州牛肉面,而非兰州拉面");
|
||||
xy_error_brkt ("xy.h", "错误", "西安肉丸胡辣汤里没有肉丸");
|
||||
|
||||
assert (false == xy_str_end_with ("abcdef", "abcdefg"));
|
||||
assert (xy_str_end_with ("abcdef", "def"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user