From 6a914d3da4563331ed5252ca0147b3fb727d1150 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Tue, 24 Sep 2024 11:58:48 +0200 Subject: [PATCH] journal I use logs to structure the project better --- include/fsm.h | 11 +++++------ src/fsm/dispatch.c | 19 ++++++++++++------- src/fsm/measures/manager.c | 4 ++-- src/fsm/measures/tool_list.c | 23 +++++++++++++++-------- src/fsm/preferences/manager.c | 8 ++++++-- src/fsm/results/manager.c | 4 ++-- src/journal.c | 2 +- src/main.c | 11 +++++++---- src/signal.c | 8 +++++--- src/util/tests.c | 2 ++ src/widget/all_rules/tree/dispatch.c | 2 ++ src/widget/dispatch.c | 5 +++-- src/widget/one_rule/algebra/conditions.c | 2 +- src/widget/one_rule/dispatch.c | 2 ++ src/widget/topbar/dialog.c | 3 ++- src/widget/topbar/dispatch.c | 10 ++++++++-- src/widget/topbar/left.c | 2 +- src/widget/topbar/modal.c | 3 ++- src/widget/topbar/right.c | 2 +- 19 files changed, 79 insertions(+), 44 deletions(-) diff --git a/include/fsm.h b/include/fsm.h index b14ed63..4a4f76e 100644 --- a/include/fsm.h +++ b/include/fsm.h @@ -56,8 +56,8 @@ typedef struct disp_list {int value; struct disp_list *suiv;} disp_list ; * Un seul fsm_journal_event() par fonction * ? 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 -* ils doivent avoir la même étiquette : MESSAGE, SOURCE, TARGET +* S'il y a deux fsm_journal_event() (begin / end) dans une fonction, +* 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 - * * * */ @@ -70,7 +70,8 @@ enum source { MAIN_WINDOW, DIALOG_WINDOW, MODAL_WINDOW, TEXT_WINDOW, AUTO_NOTIFICATION, TOPBAR, TOPBAR_LEFT, TOPBAR_RIGHT, TOPBAR_CENTER, 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, RULE_GEOMETRY, RULE_GLAREA, RULE_CAMERA, RULE_ALGEBRA, RULE_CONDITION, RULE_ASSIGN, RULE_ID, @@ -83,8 +84,6 @@ enum source { SLIDER_A, SLIDER_B, SLIDER_C, }; -enum value {VALUE}; // to use or not to use ... (plutôt non) - #define JOURNAL_LOG_MAX_LENGTH 255 typedef struct unit {long yy_dd_mm; @@ -122,7 +121,7 @@ void fsm_journal_publish (journal jj); // display the journ // ----------------------------------------------------------------------------- // ref: sudo cat /var/log/messages // journal fsm_get_journal(); // def: fsm/dispatch call: fsm/prefer/fsm_store_restore_reset() -void fsm_journal_publication_request (); // def: fsm/dispatch call: main; +void fsm_journal_publication_request(); // def: fsm/dispatch call: main; void fsm_journal_event (int severity, int source, const char *file_source, diff --git a/src/fsm/dispatch.c b/src/fsm/dispatch.c index 9c76800..e28b43d 100644 --- a/src/fsm/dispatch.c +++ b/src/fsm/dispatch.c @@ -58,7 +58,7 @@ /******************************************************************************/ static journal gg_logs; -void fsm_journal_publication_request () {fsm_journal_publish (gg_logs);} +void fsm_journal_publication_request() {fsm_journal_publish (gg_logs);} // CRITICAL ERROR WARNING INFO MESSAGE DEBUG SPEW // 0 1 2 3 4 5 6 @@ -83,23 +83,28 @@ void fsm_journal_event (int severity, void fsm_init (char *initial_message_from_main) { 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", "measures list init()", ""); + fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "measures list init()", + "measurement processes"); 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_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_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_journal_event (MESSAGE, FSM, "fsm/dispatch", "fsm initialisation", "has ended"); + fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "fsm initialisation", + "has ended 😇️ | 👉️ app initialization begins"); } diff --git a/src/fsm/measures/manager.c b/src/fsm/measures/manager.c index 61e086d..cc4d1b1 100644 --- a/src/fsm/measures/manager.c +++ b/src/fsm/measures/manager.c @@ -103,8 +103,8 @@ void fsm_measures_list_init() fsm_journal_event (DEBUG, RESULTS, "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) {} diff --git a/src/fsm/measures/tool_list.c b/src/fsm/measures/tool_list.c index 1f65249..219ce32 100644 --- a/src/fsm/measures/tool_list.c +++ b/src/fsm/measures/tool_list.c @@ -93,7 +93,6 @@ int fsm_tools_list_pop (tool_list **ml) if (! *ml) return -1; tmp = (*ml)->suiv; value = (*ml)->value; - printf("value = %d < removed from the measures list\n", (*ml)->value); free (*ml); *ml = tmp; return value; @@ -141,7 +140,8 @@ void fsm_tools_list_test() { 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,5); 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_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); - puts("ajout des 2 elements (3, 1) :"); - fsm_tools_list_insert (&ex_tool,3); - fsm_tools_list_insert (&ex_tool,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, 1); fsm_tools_list_view (ex_tool); fsm_tools_list_clear (&ex_tool); - printf("clear()\n> nombre d'éléments restant = %d\n\n", - fsm_tools_list_length(ex_tool)); + // char string_value [10]; if one wants to check the list length: 0 + // 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"); } + diff --git a/src/fsm/preferences/manager.c b/src/fsm/preferences/manager.c index 5d5f910..fe37e89 100644 --- a/src/fsm/preferences/manager.c +++ b/src/fsm/preferences/manager.c @@ -130,11 +130,15 @@ void fsm_add_displayable (char *displayable_name) /******************************************************************************/ 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 () { - 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)"); } diff --git a/src/fsm/results/manager.c b/src/fsm/results/manager.c index c306c1c..efa01ec 100644 --- a/src/fsm/results/manager.c +++ b/src/fsm/results/manager.c @@ -73,7 +73,7 @@ void fsm_results_list_init () fsm_journal_event (DEBUG, RESULTS, "fsm/results/manager", - "fsm results list < ready to use", - ""); + "fsm results list is ready to use", + "(double chained)"); } diff --git a/src/journal.c b/src/journal.c index 46a9687..2747a57 100644 --- a/src/journal.c +++ b/src/journal.c @@ -165,7 +165,7 @@ void fsm_journal_publish (journal jj) while (a_unit) { 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, a_unit->usec, nb, diff --git a/src/main.c b/src/main.c index db8040a..ee55cec 100644 --- a/src/main.c +++ b/src/main.c @@ -134,12 +134,14 @@ int main (int argc, char **argv) { // def: src/fsm/dispatch fsm = finite state machine 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", G_APPLICATION_DEFAULT_FLAGS); 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()' // and 'on_windows_startup()' are in: src/widget/dispatch.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); 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); - 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(); return status; diff --git a/src/signal.c b/src/signal.c index 666caae..7be6b3d 100644 --- a/src/signal.c +++ b/src/signal.c @@ -253,7 +253,9 @@ static void switch_state_rules_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 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 = gtk_check_button_get_label (GTK_CHECK_BUTTON (toggled_button)); - fsm_journal_event (DEBUG, BUTTON, - "signal", "toggled button:", concat ("[", toggled_button_name, "]", NULL)); + fsm_journal_event (DEBUG, BUTTON, "signal", "toggle_state_rules_data()", + concat ("change of status requested", ": [", toggled_button_name, "]", NULL)); 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); diff --git a/src/util/tests.c b/src/util/tests.c index ae07aae..54c24ce 100644 --- a/src/util/tests.c +++ b/src/util/tests.c @@ -30,9 +30,11 @@ #include "../../include/util.h" #include "../../include/base.h" +#include "../../include/fsm.h" void util_trigger_test () { + if (0) fsm_tools_list_test(); if (0) util_pile_test(); if (0) util_double_list_test(); if (0) util_sorted_list_test(); diff --git a/src/widget/all_rules/tree/dispatch.c b/src/widget/all_rules/tree/dispatch.c index 05886de..b1807d3 100644 --- a/src/widget/all_rules/tree/dispatch.c +++ b/src/widget/all_rules/tree/dispatch.c @@ -31,6 +31,8 @@ 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)); 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))); diff --git a/src/widget/dispatch.c b/src/widget/dispatch.c index 9cd6c1b..ccfb4c6 100644 --- a/src/widget/dispatch.c +++ b/src/widget/dispatch.c @@ -61,7 +61,7 @@ void *widget_get_text_window() { return text_window; } void on_windows_startup (GtkApplication *app) // WIP 2024-09 { // 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) @@ -102,7 +102,8 @@ void on_windows_activation (GtkApplication *app) g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (act_b)); 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"); } /******************************************************************************/ diff --git a/src/widget/one_rule/algebra/conditions.c b/src/widget/one_rule/algebra/conditions.c index b16a2ba..5cbca37 100644 --- a/src/widget/one_rule/algebra/conditions.c +++ b/src/widget/one_rule/algebra/conditions.c @@ -78,7 +78,7 @@ void *widget_get_btt_conditions_list() RULE_CONDITION, "one_rule/algebra/conditions", concat ("list; last of ", str_nb, " conditions: ", NULL), - concat ("[", one_condition, "]", NULL)); + concat ("[", one_condition, "]", " <-- a cond. sample", NULL)); return conditions; } diff --git a/src/widget/one_rule/dispatch.c b/src/widget/one_rule/dispatch.c index a7cbb81..0663df8 100644 --- a/src/widget/one_rule/dispatch.c +++ b/src/widget/one_rule/dispatch.c @@ -31,6 +31,8 @@ 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)); 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))); diff --git a/src/widget/topbar/dialog.c b/src/widget/topbar/dialog.c index 063a666..88497c8 100644 --- a/src/widget/topbar/dialog.c +++ b/src/widget/topbar/dialog.c @@ -36,7 +36,8 @@ 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? "; GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ()); gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title)); diff --git a/src/widget/topbar/dispatch.c b/src/widget/topbar/dispatch.c index f597ef4..d7d3013 100644 --- a/src/widget/topbar/dispatch.c +++ b/src/widget/topbar/dispatch.c @@ -39,18 +39,24 @@ static GtkWidget *window_topbar (GtkWindow *window); 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); window_design_topbar_left (topbar); 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)); } 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)"; GtkWidget *topbar = GTK_WIDGET (gtk_header_bar_new ()); gtk_header_bar_set_title_widget (GTK_HEADER_BAR (topbar), gtk_label_new (title)); diff --git a/src/widget/topbar/left.c b/src/widget/topbar/left.c index 1a3a896..e807bdb 100644 --- a/src/widget/topbar/left.c +++ b/src/widget/topbar/left.c @@ -44,7 +44,7 @@ void *widget_get_btt_data () {return btt_DATA;} void window_design_topbar_left (GtkWidget *header_bar) { 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; GtkButton *btt_XOR_EXEC_EDIT = GTK_BUTTON (gtk_toggle_button_new ()); diff --git a/src/widget/topbar/modal.c b/src/widget/topbar/modal.c index 0a82359..9049d29 100644 --- a/src/widget/topbar/modal.c +++ b/src/widget/topbar/modal.c @@ -35,7 +35,8 @@ 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. "; GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ()); gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title)); diff --git a/src/widget/topbar/right.c b/src/widget/topbar/right.c index 54c1b10..ebfdcb9 100644 --- a/src/widget/topbar/right.c +++ b/src/widget/topbar/right.c @@ -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) { - 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); GSimpleActionGroup *ga = g_simple_action_group_new ();