Log remarkbly

This commit is contained in:
Aoran Zeng 2024-06-08 07:13:38 +08:00
parent 64ef33cb19
commit 7e591ff025

View File

@ -3,7 +3,7 @@
* License : MIT * License : MIT
* Authors : Aoran Zeng <ccmywish@qq.com> * Authors : Aoran Zeng <ccmywish@qq.com>
* Created on : <2023-08-28> * Created on : <2023-08-28>
* Last modified : <2024-04-18> * Last modified : <2024-06-08>
* *
* xy: * xy:
* *
@ -17,7 +17,7 @@
#ifndef XY_H #ifndef XY_H
#define XY_H #define XY_H
#define XY_Version "v0.1.1-2024/04/18" #define XY_Version "v0.1.2-2024/06/08"
#define XY_Maintain_URL "https://gitee.com/RubyMetric/chsrc/blob/main/xy.h" #define XY_Maintain_URL "https://gitee.com/RubyMetric/chsrc/blob/main/xy.h"
#include <assert.h> #include <assert.h>
@ -162,6 +162,11 @@ _xy_log (int level, const char *str)
free (buf); free (buf);
} }
/******************************************************
* String
******************************************************/
/** /**
* str中所有的pat字符串替换成replace * str中所有的pat字符串替换成replace
*/ */
@ -479,6 +484,47 @@ xy_str_strip (const char *str)
return new; return new;
} }
/******************************************************
* Logging
******************************************************/
/**
* remarkably pip 便使xy.h的程序应该基于此再定义自己的 app_info_remarkbaly()
* [app ] [app info]
* [app ] [app notice]
*/
void
xy_info_remarkably (const char* prompt1, const char *prompt2, const char *content)
{
puts (
xy_strjoin (6, "[", prompt1, " ", xy_str_to_blue (prompt2), "] ", xy_str_to_blue (content))
);
}
/**
* [app ] [app warn]
*/
void
xy_warn_remarkably (const char* prompt1, const char *prompt2, const char *content)
{
char *buf = xy_strjoin (6, "[", prompt1, " ", xy_str_to_yellow (prompt2), "] ", xy_str_to_yellow (content));
fprintf (stderr, "%s\n", buf);
}
/**
* [app ] [app error]
*/
void
xy_error_remarkably (const char* prompt1, const char *prompt2, const char *content)
{
char *buf = xy_strjoin (6, "[", prompt1, " ", xy_str_to_red (prompt2), "] ", xy_str_to_red (content));
fprintf (stderr, "%s\n", buf);
}
/******************************************************
* System
******************************************************/
/** /**
* cmd * cmd
* *