mirror of
https://github.com/rtbrick/bngblaster.git
synced 2024-05-06 15:54:57 +00:00
add log message buffer
The log message buffer is used to display in the ncurses log window even those messages logged before ncurses has started.
This commit is contained in:
committed by
Christian Giese
parent
842d0103e4
commit
b41d4947ab
@@ -23,7 +23,11 @@
|
||||
bbl_ctx_s *g_ctx = NULL;
|
||||
|
||||
/* Global Variables */
|
||||
bool g_interactive = false; /* interactive mode using ncurses */
|
||||
bool g_interactive = false; /* interactive mode using ncurses */
|
||||
|
||||
uint8_t g_log_buf_cur = 0;
|
||||
char *g_log_buf = NULL;
|
||||
|
||||
bool g_init_phase = true;
|
||||
bool g_traffic = true;
|
||||
bool g_banner = true;
|
||||
@@ -444,6 +448,7 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
case 'I':
|
||||
interactive = true;
|
||||
bbl_interactive_log_buf_init();
|
||||
break;
|
||||
case 'S':
|
||||
g_ctx->ctrl_socket_path = optarg;
|
||||
|
||||
@@ -57,6 +57,51 @@ uint32_t g_session_selected = 1;
|
||||
|
||||
extern const char banner[];
|
||||
|
||||
/*
|
||||
* The log message buffer is used to display in the ncurses log window
|
||||
* even those messages logged before ncurses has started.
|
||||
*/
|
||||
|
||||
extern char *g_log_buf;
|
||||
extern uint8_t g_log_buf_cur;
|
||||
|
||||
void
|
||||
bbl_interactive_log_buf_init()
|
||||
{
|
||||
if(g_log_buf) {
|
||||
free(g_log_buf);
|
||||
}
|
||||
g_log_buf = calloc(LOG_BUF_LINES, LOG_BUF_STR_LEN);
|
||||
g_log_buf_cur = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
bbl_interactive_log_buf_free()
|
||||
{
|
||||
int i = 0;
|
||||
char *line = NULL;
|
||||
if(!g_log_buf) {
|
||||
return;
|
||||
}
|
||||
for(i = g_log_buf_cur; i < LOG_BUF_LINES; i++) {
|
||||
line = g_log_buf+(i*LOG_BUF_STR_LEN);
|
||||
if(!strnlen(line, LOG_BUF_STR_LEN)) {
|
||||
break;
|
||||
}
|
||||
wprintw(log_win, "%s", line);
|
||||
}
|
||||
for(i = 0; i < g_log_buf_cur; i++) {
|
||||
line = g_log_buf+(i*LOG_BUF_STR_LEN);
|
||||
if(!strnlen(line, LOG_BUF_STR_LEN)) {
|
||||
break;
|
||||
}
|
||||
wprintw(log_win, "%s", line);
|
||||
}
|
||||
wrefresh(log_win);
|
||||
free(g_log_buf);
|
||||
g_log_buf = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Format a progress bar.
|
||||
*/
|
||||
@@ -680,6 +725,7 @@ bbl_interactive_init()
|
||||
bbl_interactive_init_window();
|
||||
wrefresh(stats_win);
|
||||
|
||||
bbl_interactive_log_buf_free();
|
||||
g_interactive = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#ifndef __BBL_INTERACTIVE_H__
|
||||
#define __BBL_INTERACTIVE_H__
|
||||
|
||||
void
|
||||
bbl_interactive_log_buf_init();
|
||||
|
||||
void
|
||||
bbl_interactive_init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user