journal I use logs to structure the project better

This commit is contained in:
Jean Sirmai 2024-09-24 11:58:48 +02:00
parent 1786f9fa16
commit 6a914d3da4
Signed by: jean
GPG Key ID: FB3115C340E057E3
19 changed files with 79 additions and 44 deletions

View File

@ -56,8 +56,8 @@ typedef struct disp_list {int value; struct disp_list *suiv;} disp_list ;
* Un seul fsm_journal_event() par fonction * Un seul fsm_journal_event() par fonction
* ? sauf si cette fonction génère plusieurs autres fonctions d'intérêt ? * ? sauf si cette fonction génère plusieurs autres fonctions d'intérêt ?
* *
* S'il y a deux fsm_journal_event() (begin / end) dans une fonction * S'il y a deux fsm_journal_event() (begin / end) dans une fonction,
* ils doivent avoir la même étiquette : MESSAGE, SOURCE, TARGET * ils doivent avoir la même étiquette (les mêmes valeurs) : SEVERITY & SOURCE
* *
* * * * * - J O U R N A L M E T A R U L E S - * * * */ * * * * * - J O U R N A L M E T A R U L E S - * * * */
@ -70,7 +70,8 @@ enum source {
MAIN_WINDOW, DIALOG_WINDOW, MODAL_WINDOW, TEXT_WINDOW, AUTO_NOTIFICATION, MAIN_WINDOW, DIALOG_WINDOW, MODAL_WINDOW, TEXT_WINDOW, AUTO_NOTIFICATION,
TOPBAR, TOPBAR_LEFT, TOPBAR_RIGHT, TOPBAR_CENTER, TOPBAR, TOPBAR_LEFT, TOPBAR_RIGHT, TOPBAR_CENTER,
SYNTH_PAGE, STATE_PAGE, RULES_PAGE, MEASURES_PAGE, RESULTS_PAGE, SYNTH_PAGE, STATE_PAGE, RULES_PAGE, MEASURES_PAGE, RESULTS_PAGE,
SYNTH_GLAREA, SYNTH_ALL_RESULTS, SYNTH_TIME_DEP_RESULTS, SYNTH_TIME_INDEP_RESULTS, SYNTH_GLAREA, SYNTH_ALL_RESULTS,
SYNTH_TIME_DEP_RESULTS, SYNTH_TIME_INDEP_RESULTS,
STATE_TOP, STATE_BOTTOM, STATE_GLAREA, STATE_CAMERA, STATE_TOP, STATE_BOTTOM, STATE_GLAREA, STATE_CAMERA,
RULE_GEOMETRY, RULE_GLAREA, RULE_CAMERA, RULE_GEOMETRY, RULE_GLAREA, RULE_CAMERA,
RULE_ALGEBRA, RULE_CONDITION, RULE_ASSIGN, RULE_ID, RULE_ALGEBRA, RULE_CONDITION, RULE_ASSIGN, RULE_ID,
@ -83,8 +84,6 @@ enum source {
SLIDER_A, SLIDER_B, SLIDER_C, SLIDER_A, SLIDER_B, SLIDER_C,
}; };
enum value {VALUE}; // to use or not to use ... (plutôt non)
#define JOURNAL_LOG_MAX_LENGTH 255 #define JOURNAL_LOG_MAX_LENGTH 255
typedef struct unit {long yy_dd_mm; typedef struct unit {long yy_dd_mm;

View File

@ -83,23 +83,28 @@ void fsm_journal_event (int severity,
void fsm_init (char *initial_message_from_main) void fsm_init (char *initial_message_from_main)
{ {
fsm_journal_init (&gg_logs); fsm_journal_init (&gg_logs);
fsm_journal_event (MESSAGE, MAIN, "main", initial_message_from_main, ""); fsm_journal_event (MESSAGE, MAIN, "main", initial_message_from_main, "👋️ (☕️)");
fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "fsm initialisation", "has began"); fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "fsm initialisation", "has began");
fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "measures list init()", ""); fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "measures list init()",
"measurement processes");
fsm_measures_list_init(); fsm_measures_list_init();
fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "results list init()", ""); fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "results list init()",
"measurement results (gross)");
fsm_results_list_init(); fsm_results_list_init();
fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "displayables list init()", ""); fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "displayables list init()",
"displayable results");
fsm_displayables_list_init(); fsm_displayables_list_init();
fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "preferences list init()", ""); fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "preferences list init()",
"preferences");
fsm_preferences_list_init(); fsm_preferences_list_init();
fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "fsm initialisation", "has ended"); fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "fsm initialisation",
"has ended 😇️ | 👉️ app initialization begins");
} }

View File

@ -103,8 +103,8 @@ void fsm_measures_list_init()
fsm_journal_event (DEBUG, fsm_journal_event (DEBUG,
RESULTS, RESULTS,
"fsm/measures/manager", "fsm/measures/manager",
"fsm measures list < ready to use", "fsm measures list is ready to use",
""); "(double chained)");
} }
void fsm_rule_trig_measure (int rule_id, int object_id, int measure_id) {} void fsm_rule_trig_measure (int rule_id, int object_id, int measure_id) {}

View File

@ -93,7 +93,6 @@ int fsm_tools_list_pop (tool_list **ml)
if (! *ml) return -1; if (! *ml) return -1;
tmp = (*ml)->suiv; tmp = (*ml)->suiv;
value = (*ml)->value; value = (*ml)->value;
printf("value = %d < removed from the measures list\n", (*ml)->value);
free (*ml); free (*ml);
*ml = tmp; *ml = tmp;
return value; return value;
@ -141,7 +140,8 @@ void fsm_tools_list_test()
{ {
tool_list *ex_tool = NULL; tool_list *ex_tool = NULL;
puts("\nfsm/measure/ fsm_tools_list_test() > création d'une liste de 6 elements :"); fsm_journal_event (DEBUG, MEASURES_TOOLS, "fsm/measure/",
"fsm_tools_list_test()", "création d'une liste de 6 elements:");
fsm_tools_list_insert (&ex_tool,-3); fsm_tools_list_insert (&ex_tool,-3);
fsm_tools_list_insert (&ex_tool,5); fsm_tools_list_insert (&ex_tool,5);
fsm_tools_list_insert (&ex_tool,-1); fsm_tools_list_insert (&ex_tool,-1);
@ -150,18 +150,25 @@ void fsm_tools_list_test()
fsm_tools_list_insert (&ex_tool,0); fsm_tools_list_insert (&ex_tool,0);
fsm_tools_list_view (ex_tool); fsm_tools_list_view (ex_tool);
puts("retrait des 2 premiers elements :"); fsm_journal_event (DEBUG, MEASURES_TOOLS, "fsm/measure/",
"fsm_tools_list_test()",
"retrait des 2 premiers elements:");
fsm_tools_list_pop (&ex_tool); fsm_tools_list_pop (&ex_tool);
fsm_tools_list_pop (&ex_tool); fsm_tools_list_pop (&ex_tool);
puts("ajout des 2 elements (3, 1) :"); fsm_journal_event (DEBUG, MEASURES_TOOLS, "fsm/measure/",
"fsm_tools_list_test()",
"ajout des 2 elements (3, 1):");
fsm_tools_list_insert (&ex_tool, 3); fsm_tools_list_insert (&ex_tool, 3);
fsm_tools_list_insert (&ex_tool, 1); fsm_tools_list_insert (&ex_tool, 1);
fsm_tools_list_view (ex_tool); fsm_tools_list_view (ex_tool);
fsm_tools_list_clear (&ex_tool); fsm_tools_list_clear (&ex_tool);
printf("clear()\n> nombre d'éléments restant = %d\n\n", // char string_value [10]; if one wants to check the list length: 0
fsm_tools_list_length(ex_tool)); // sprintf(string_value, " (%d)", fsm_tools_list_length (ex_tool));
fsm_journal_event (DEBUG, MEASURES_TOOLS, "fsm/measure/",
"fsm_tools_list_test()","clear() > 0 élément restant");
} }

View File

@ -130,11 +130,15 @@ void fsm_add_displayable (char *displayable_name)
/******************************************************************************/ /******************************************************************************/
void fsm_preferences_list_init () void fsm_preferences_list_init ()
{ {
fsm_journal_event (MESSAGE, PREFER, "fsm/preferences/manager", "fsm preferences list < ready to use", ""); fsm_journal_event (MESSAGE, PREFER, "fsm/preferences/manager",
"fsm preferences list is ready to use",
"(double chained)");
} }
void fsm_displayables_list_init () void fsm_displayables_list_init ()
{ {
fsm_journal_event (MESSAGE, PREFER, "fsm/preferences/manager", "fsm displayables list < ready to use", ""); fsm_journal_event (MESSAGE, PREFER, "fsm/preferences/manager",
"fsm displayables list is ready to use",
"(double chained)");
} }

View File

@ -73,7 +73,7 @@ void fsm_results_list_init ()
fsm_journal_event (DEBUG, fsm_journal_event (DEBUG,
RESULTS, RESULTS,
"fsm/results/manager", "fsm/results/manager",
"fsm results list < ready to use", "fsm results list is ready to use",
""); "(double chained)");
} }

View File

@ -165,7 +165,7 @@ void fsm_journal_publish (journal jj)
while (a_unit) while (a_unit)
{ {
strftime(buf, sizeof(buf), "%D %T", localtime(&a_unit->yy_dd_mm)); strftime(buf, sizeof(buf), "%D %T", localtime(&a_unit->yy_dd_mm));
g_message ("%s + %-6ld %6d %-32s %-36s %-50s", g_message ("%s + %-6ld %6d %-32s %-38s %-50s",
buf, buf,
a_unit->usec, a_unit->usec,
nb, nb,

View File

@ -134,12 +134,14 @@ int main (int argc, char **argv)
{ {
// def: src/fsm/dispatch fsm = finite state machine // def: src/fsm/dispatch fsm = finite state machine
fsm_init ("first instruction / first log"); fsm_init ("first instruction / first log");
fsm_journal_event (INFO, MAIN, "main", "*app = gtk_application_new ()", ""); fsm_journal_event (INFO, MAIN, "main", "*app = gtk_application_new()",
"new app requested");
GtkApplication *app = gtk_application_new ("org.gem-graph", GtkApplication *app = gtk_application_new ("org.gem-graph",
G_APPLICATION_DEFAULT_FLAGS); G_APPLICATION_DEFAULT_FLAGS);
fsm_journal_event (INFO, MAIN, "main", fsm_journal_event (INFO, MAIN, "main",
"g signal connect", "(app <--> on_windows_startup & activate)"); "g signal connect (activate)",
"| 👉️ windows creation requested");
// ! WARNING ! 'on_windows_activation()' // ! WARNING ! 'on_windows_activation()'
// and 'on_windows_startup()' are in: src/widget/dispatch.c // and 'on_windows_startup()' are in: src/widget/dispatch.c
// NOT in: src/signal.c // NOT in: src/signal.c
@ -147,10 +149,11 @@ int main (int argc, char **argv)
g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL); g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL);
int status = g_application_run (G_APPLICATION (app), argc, argv); int status = g_application_run (G_APPLICATION (app), argc, argv);
fsm_journal_event (INFO, MAIN, "main", "g_object unref (app)", ""); fsm_journal_event (INFO, MAIN, "main", "g_object unref (app)", "bye bye app !");
g_object_unref (app); g_object_unref (app);
fsm_journal_event (INFO, MAIN, "main", "That'all folks ! 👋️😄️", ""); fsm_journal_event (INFO, MAIN, "main", "That'all folks !", "👋️😄️\
\n NB I use logs to structure the project better.");
fsm_journal_publication_request(); fsm_journal_publication_request();
return status; return status;

View File

@ -253,7 +253,9 @@ static void switch_state_rules_data();
void on_toggle_exec_edit (GtkWidget *toggled_button, gpointer user_data) void on_toggle_exec_edit (GtkWidget *toggled_button, gpointer user_data)
{ {
fsm_journal_event (INFO, BUTTON, "signal", "(Xec/Ed) toggle exec edit()", ""); fsm_journal_event (INFO, BUTTON, "signal", "toggle exec edit()",
"change of status requested");
if (fsm_get_exec_edit ()) { // TODO (or NOT ?) et si je ne suis pas sur la page SYNTH if (fsm_get_exec_edit ()) { // TODO (or NOT ?) et si je ne suis pas sur la page SYNTH
gtk_button_set_icon_name (GTK_BUTTON (toggled_button), gtk_button_set_icon_name (GTK_BUTTON (toggled_button),
@ -345,8 +347,8 @@ void on_toggle_state_rules_data (GtkWidget *toggled_button, gpointer user_data)
{ {
const char *toggled_button_name const char *toggled_button_name
= gtk_check_button_get_label (GTK_CHECK_BUTTON (toggled_button)); = gtk_check_button_get_label (GTK_CHECK_BUTTON (toggled_button));
fsm_journal_event (DEBUG, BUTTON, fsm_journal_event (DEBUG, BUTTON, "signal", "toggle_state_rules_data()",
"signal", "toggled button:", concat ("[", toggled_button_name, "]", NULL)); concat ("change of status requested", ": [", toggled_button_name, "]", NULL));
int is_active = gtk_check_button_get_active (GTK_CHECK_BUTTON (toggled_button)); int is_active = gtk_check_button_get_active (GTK_CHECK_BUTTON (toggled_button));
if ( ! strcmp (toggled_button_name, "synth")) fsm_set_state_rules_data (SYNTH); if ( ! strcmp (toggled_button_name, "synth")) fsm_set_state_rules_data (SYNTH);

View File

@ -30,9 +30,11 @@
#include "../../include/util.h" #include "../../include/util.h"
#include "../../include/base.h" #include "../../include/base.h"
#include "../../include/fsm.h"
void util_trigger_test () void util_trigger_test ()
{ {
if (0) fsm_tools_list_test();
if (0) util_pile_test(); if (0) util_pile_test();
if (0) util_double_list_test(); if (0) util_double_list_test();
if (0) util_sorted_list_test(); if (0) util_sorted_list_test();

View File

@ -31,6 +31,8 @@
void *widget_get_all_rules_left_pane () void *widget_get_all_rules_left_pane ()
{ {
fsm_journal_event (INFO, TOPBAR_LEFT, "widget/all_rules/tree", "design",
"pilot box + tree tools <<< TODO");
GtkBox *rules_tree_and_pilot_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); GtkBox *rules_tree_and_pilot_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (widget_get_rules_pilot_box ())); gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (widget_get_rules_pilot_box ()));
gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));

View File

@ -61,7 +61,7 @@ void *widget_get_text_window() { return text_window; }
void on_windows_startup (GtkApplication *app) // WIP 2024-09 void on_windows_startup (GtkApplication *app) // WIP 2024-09
{ {
// NB on_windows_startup() is in: widget/dispatch NOT in: src/signal // NB on_windows_startup() is in: widget/dispatch NOT in: src/signal
fsm_journal_event (MESSAGE, WIDGETS, "widget/dispatch", "windows startup()", ""); fsm_journal_event (MESSAGE, WIDGETS, "widget/dispatch", "windows startup()", "(usage ?)");
} }
void on_windows_activation (GtkApplication *app) void on_windows_activation (GtkApplication *app)
@ -102,7 +102,8 @@ void on_windows_activation (GtkApplication *app)
g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (act_b)); g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (act_b));
g_signal_connect (act_b, "activate", G_CALLBACK (action_b), app2);*/ g_signal_connect (act_b, "activate", G_CALLBACK (action_b), app2);*/
fsm_journal_event (INFO, WIDGETS, "widget/dispatch", "windows activation()", "has ended"); fsm_journal_event (INFO, WIDGETS, "widget/dispatch", "windows activation()",
"has ended 🧐️ | 👉️ a new session can be launched");
} }
/******************************************************************************/ /******************************************************************************/

View File

@ -78,7 +78,7 @@ void *widget_get_btt_conditions_list()
RULE_CONDITION, RULE_CONDITION,
"one_rule/algebra/conditions", "one_rule/algebra/conditions",
concat ("list; last of ", str_nb, " conditions: ", NULL), concat ("list; last of ", str_nb, " conditions: ", NULL),
concat ("[", one_condition, "]", NULL)); concat ("[", one_condition, "]", " <-- a cond. sample", NULL));
return conditions; return conditions;
} }

View File

@ -31,6 +31,8 @@
void *widget_get_selected_rule() void *widget_get_selected_rule()
{ {
fsm_journal_event (INFO, TOPBAR_LEFT, "widget/one_rule/", "starting design of:",
"algebra + geometry");
GtkBox *one_rule = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); GtkBox *one_rule = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
gtk_box_append (one_rule, GTK_WIDGET (widget_get_selected_rule_algebra ())); gtk_box_append (one_rule, GTK_WIDGET (widget_get_selected_rule_algebra ()));
gtk_box_append (one_rule, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); gtk_box_append (one_rule, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));

View File

@ -36,7 +36,8 @@
void widget_design_dialog_window (GtkWindow *main_window, GtkWindow *dialog_window) void widget_design_dialog_window (GtkWindow *main_window, GtkWindow *dialog_window)
{ {
fsm_journal_event (INFO, MODAL_WINDOW, "widget/topbar/dialog", "modal window design", ""); fsm_journal_event (INFO, MODAL_WINDOW, "widget/topbar/dialog", "modal window design",
"(save data before editing ?)");
char *title = " Save the current model before modifying it? "; char *title = " Save the current model before modifying it? ";
GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ()); GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ());
gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title)); gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title));

View File

@ -39,18 +39,24 @@ static GtkWidget *window_topbar (GtkWindow *window);
void widget_design_main_window (GtkWindow *main_window, GtkApplication *app) void widget_design_main_window (GtkWindow *main_window, GtkApplication *app)
{ {
fsm_journal_event (INFO, TOPBAR, "widget/topbar/dispatch", "design (main window topbar)", ""); fsm_journal_event (INFO, TOPBAR, "widget/topbar/dispatch",
"design (main window topbar)", "has began");
GtkWidget *topbar = window_topbar (main_window); GtkWidget *topbar = window_topbar (main_window);
window_design_topbar_left (topbar); window_design_topbar_left (topbar);
window_design_topbar_right (topbar, app); window_design_topbar_right (topbar, app);
fsm_journal_event (INFO, TOPBAR, "widget/topbar/dispatch",
"design (main window topbar)", "has ended");
gtk_window_present (GTK_WINDOW (main_window)); gtk_window_present (GTK_WINDOW (main_window));
} }
static GtkWidget *window_topbar (GtkWindow *window) static GtkWidget *window_topbar (GtkWindow *window)
{ {
fsm_journal_event (INFO, TOPBAR_CENTER, "widget/topbar/dispatch", "topbar = gtk_header_bar_new()", ""); fsm_journal_event (INFO, TOPBAR_CENTER, "widget/topbar/dispatch",
"gtk_header_bar_new()", "gtk_header_bar_set_title_widget() + _set_titlebar()");
char *title = "E coli (with permission from David S. Goodsell, 2009)"; char *title = "E coli (with permission from David S. Goodsell, 2009)";
GtkWidget *topbar = GTK_WIDGET (gtk_header_bar_new ()); GtkWidget *topbar = GTK_WIDGET (gtk_header_bar_new ());
gtk_header_bar_set_title_widget (GTK_HEADER_BAR (topbar), gtk_label_new (title)); gtk_header_bar_set_title_widget (GTK_HEADER_BAR (topbar), gtk_label_new (title));

View File

@ -44,7 +44,7 @@ void *widget_get_btt_data () {return btt_DATA;}
void window_design_topbar_left (GtkWidget *header_bar) void window_design_topbar_left (GtkWidget *header_bar)
{ {
fsm_journal_event (INFO, TOPBAR_LEFT, "widget/topbar/left", "design (topbar left)", fsm_journal_event (INFO, TOPBAR_LEFT, "widget/topbar/left", "design (topbar left)",
"(EXEC / EDIT) and (SYNTH / STATE / RULES / DATA)"); "(exec-edit) & (synth state rules data)");
gpointer no_local_data = NULL; gpointer no_local_data = NULL;
GtkButton *btt_XOR_EXEC_EDIT = GTK_BUTTON (gtk_toggle_button_new ()); GtkButton *btt_XOR_EXEC_EDIT = GTK_BUTTON (gtk_toggle_button_new ());

View File

@ -35,7 +35,8 @@
void widget_design_text_window (GtkWindow *main_window, GtkWindow *text_window) void widget_design_text_window (GtkWindow *main_window, GtkWindow *text_window)
{ {
fsm_journal_event (INFO, TEXT_WINDOW, "widget/topbar/modal", "text window design", ""); fsm_journal_event (INFO, TEXT_WINDOW, "widget/topbar/modal", "text window design",
"(documentation)");
char *title = " Learn more about Gem Graph. "; char *title = " Learn more about Gem Graph. ";
GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ()); GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ());
gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title)); gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title));

View File

@ -93,7 +93,7 @@ static void connect(GApplication *app, gpointer *data) { puts("Connect menu item
void window_design_topbar_right (GtkWidget *header_bar, GtkApplication *app) void window_design_topbar_right (GtkWidget *header_bar, GtkApplication *app)
{ {
fsm_journal_event (INFO, TOPBAR_RIGHT, "widget/topbar/right", "design (topbar right)", ""); fsm_journal_event (INFO, TOPBAR_RIGHT, "widget/topbar/right", "design (topbar right)", "(menus)");
display_widgets_at_the_right_side (header_bar); display_widgets_at_the_right_side (header_bar);
GSimpleActionGroup *ga = g_simple_action_group_new (); GSimpleActionGroup *ga = g_simple_action_group_new ();