/!\ updates in function names

ll_sendp -> ll_send
deleted ll_send
delete LEVEL_BLABLA
This commit is contained in:
Milang 2020-04-04 14:35:22 +02:00
parent 9c795cc29e
commit a63fa46420
2 changed files with 44 additions and 92 deletions

View File

@ -9,13 +9,13 @@
#include <gint/timer.h>
#ifdef FX9860G
static int number_max_messages=4096; // Ram 4Ko
static unsigned int number_max_messages=4096; // Ram 4Ko
#define MAX_LENGHT 22
#define WIDTH 8
#endif
#ifdef FXCG50
static int number_max_messages=10000; // Ram 10 Ko
static unsigned int number_max_messages=10000; // Ram 10 Ko
#define MAX_LENGHT 132
#define WIDTH 17
#endif
@ -73,26 +73,9 @@ void ll_set_size(int s)
optimize();
}
int ll_get_size();
void ll_set_state(log_state_t s)
{
if (s==LOG_DISABLE)
priority=LEVEL_QUIET;
if (s==LOG_ENABLE)
priority=LEVEL_INFO;
}
log_state_t ll_get_state()
{
if (priority=LEVEL_QUIET)
return 0;
else
return 1;
}
static void link_line(log_line* line)
@ -181,7 +164,7 @@ static void append_character(char c)
}
// log something
void ll_send(const char * txt)
static void ll_send_internal(const char * txt)
{
if (priority!=LEVEL_QUIET)
{
@ -196,7 +179,7 @@ void ll_send(const char * txt)
}
}
void ll_sendp(log_level_t p, char const *format, ...)
void ll_send(log_level_t p, char const *format, ...)
{
if (p>=priority)
{
@ -206,16 +189,16 @@ void ll_sendp(log_level_t p, char const *format, ...)
va_start(args, format);
vsnprintf(str, 512, format, args);
va_end(args);
ll_send(str);
ll_send_internal(str);
}
}
static void show_line(const log_line* l, int y)
{
font_t * f=dfont(0);
font_t const * f=dfont(0);
dtext(1, y, &l->text[0], C_BLACK, C_NONE);
@ -282,9 +265,9 @@ void ll_pause()
GNORETURN void ll_panic(uint32_t code)
{
char str[10];
sprintf(str, "\nException !\n>> ErrCode=%d",code);
ll_set_state(1);
ll_send(str);
sprintf(str, "\nException !\n>> ErrCode=%d\nUse restart :(",code);
ll_set_level(LEVEL_INFO);
ll_send(LEVEL_FATAL, str);
while (1)
ll_pause();
}
@ -304,4 +287,4 @@ void ll_set_level(log_level_t l)
log_level_t ll_get_level(void)
{
return priority;
}
}

View File

@ -1,92 +1,61 @@
#ifndef LLOG
#define LLOG
/** Liblog Commands Table
State [deprecated, see "Log level"]
Verbosity
Editing
Advanced behaviour
*/
/** Liblog Commands Table
* State [deprecated, see "Log level"]
* Verbosity
* Editing
* Advanced behaviour
**/
/* ll_clear():
Reset log */
void ll_clear(void);
/*** [deprecated] Log state
-> using "Log level" is recommended
Enables or disable the log state
It increases performances and then you can choose to enable|disable logging during execution */
typedef enum {LOG_ENABLE=0,LOG_DISABLE=1} log_state_t;
/* ll_set_state(log_state_t):
sets log state */
void ll_set_state(log_state_t);
/* ll_get_state():
return log state */
log_state_t ll_get_state(void);
/*** Log level:
Customs verbosities for the log stream ->messages have custom levels
Default value is LEVEL_INFO
LEVEL_QUIET disables all types of messages */
typedef enum {LEVEL_BLABLA=0, LEVEL_INFO, LEVEL_WARNING, LEVEL_CRITICAL, LEVEL_FATAL, LEVEL_QUIET} log_level_t;
/** Log level:
* Customs verbosities for the log stream ->messages have custom levels
* Default value is LEVEL_INFO, all messages will be accepted
* LEVEL_QUIET disables all types of messages
**/
typedef enum {LEVEL_INFO=0, LEVEL_WARNING, LEVEL_CRITICAL, LEVEL_FATAL, LEVEL_QUIET} log_level_t;
/* ll_set_level(log_level_t):
sets log verbosity */
sets log verbosity */
void ll_set_level(log_level_t);
/* ll_get_level():
return log level */
return log level */
log_level_t ll_get_level(void);
/** Log editing
* Use the following functions to send messages
**/
/*** Log editing
Use the following functions to send messages
These commands does support '\n' */
/* ll_send(char const *)[deprecated]:
Print text
This function sends the message with a maximal priority
It will be ignored only if the log is disabled or set to quiet (same thing) */
void ll_send(char const *);
/* ll_sendp(log_level_t priority, char const * format, ...):
Print text
This function sends the message with a custom priority
Note: A message sent with `LEVEL_QUIET` counts as a `LEVEL_MAX` log */
void ll_sendp(log_level_t p, char const *format, ...);
/* ll_clear():
Reset log */
void ll_clear(void);
/* ll_send(log_level_t priority, char const * format, ...):
Print text
This function sends the message with a custom priority
Note: A message sent with `LEVEL_QUIET` counts as a `LEVEL_MAX` log */
void ll_send(log_level_t p, char const *format, ...);
/*** Log displaying
Here are different functions to display a log
There are both in fullscreen */
Here are different functions to display a log
There are both in fullscreen */
/* ll_display():
One frame displaying
It shows the last lines of the log, without scrolling ability */
One frame displaying
It shows the last lines of the log, without scrolling ability */
void ll_display(void);
/* ll_pause():
Display log, enable scrolling with arrows, and waits the user to press Exit */
Display log, enable scrolling with arrows, and waits the user to press Exit */
void ll_pause(void);
/*** Advanced behaviour
This funciont sets the behaviour when an exception occurs
*/
/** Advanced behaviour
* This funciont sets the behaviour when an exception occurs
**/
void ll_set_panic(void);
#endif