Rename log functions

This commit is contained in:
Aoran Zeng 2024-08-08 15:49:21 +08:00
parent 8f5423f704
commit 26181611a5
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
2 changed files with 36 additions and 15 deletions

View File

@ -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;

View File

@ -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"));