From 6061e78958e4dc89e0c2ce0c9bb66973d31a7df5 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Thu, 19 Sep 2024 23:21:00 +0200 Subject: [PATCH] journal simplifying (before systematic usage) --- include/fsm.h | 11 ++++++----- src/fsm/dispatch.c | 40 +++++++++++++++------------------------- src/fsm/prefer.c | 4 ++-- src/main.c | 4 ++-- src/signal.c | 6 ++---- 5 files changed, 27 insertions(+), 38 deletions(-) diff --git a/include/fsm.h b/include/fsm.h index 300a65a..4fcde48 100644 --- a/include/fsm.h +++ b/include/fsm.h @@ -55,7 +55,7 @@ enum severity {CRITICAL, ERROR, WARNING, INFO, MESSAGE, DEBUG, SPEW}; // // CRITICAL ERROR WARNING INFO MESSAGE DEBUG SPEW (see: fsm.h) // 0 1 2 3 4 5 6 (fsm_journal_event) - +/* #define CRITICAL 0 // THE HIGHER THE PRIORITY, THE LOWER THE INDEX #define ERROR 1 #define WARNING 2 @@ -63,7 +63,7 @@ enum severity {CRITICAL, ERROR, WARNING, INFO, MESSAGE, DEBUG, SPEW}; #define INFO 4 #define DEBUG 5 #define SPEW 6 // THE_LOWER THE PRIORITY, THE HIGHER THE INDEX - +*/ /* * * * * * * - F I L T E R S - * * * * * * * * This list is duplicated in both /fsm.h and /fsm/dispatch * * * @@ -93,10 +93,11 @@ enum severity {CRITICAL, ERROR, WARNING, INFO, MESSAGE, DEBUG, SPEW}; * FSM 90 * * * This list is duplicated in both /fsm.h and /fsm/dispatch * -* * * * * * * - F I L T E R S - * * * * * * */ +* * * * * * * * * * * * * * * * * * * * */ -/* * * * * - M E T A R U L E S J O U R N A L - * * * * + +/* * * * * - J O U R N A L M E T A R U L E S - * * * * * * Un seul fsm_journal_event() par fonction * sauf si elle génère plusieurs autres fonctions d'intérêt (à surveiller) @@ -104,7 +105,7 @@ enum severity {CRITICAL, ERROR, WARNING, INFO, MESSAGE, DEBUG, SPEW}; * S'il y a deux fsm_journal_event() (begin / end) dans une fonction * ils doivent avoir la même étiquette : MESSAGE, SOURCE, TARGET * -* * * * * - M E T A R U L E S J O U R N A L - * * * */ +* * * * * - J O U R N A L M E T A R U L E S - * * * */ enum source { diff --git a/src/fsm/dispatch.c b/src/fsm/dispatch.c index 66d95f7..adf34b4 100644 --- a/src/fsm/dispatch.c +++ b/src/fsm/dispatch.c @@ -66,7 +66,7 @@ void fsm_journal_event (char *message, int priority, int source, int target) // CRITICAL ERROR WARNING INFO MESSAGE DEBUG SPEW 😄️ // 0 1 2 3 4 5 6 - if (priority == 0 //<= DEBUG + if (priority < 6 #define MAIN___DIALOG___MODAL___TOPBAR___SYNTH___RULES___MEASURES___RESULTS___😄️ 0 /* * * * * * * - S O U R C E - * * * * * * * @@ -94,30 +94,20 @@ void fsm_journal_event (char *message, int priority, int source, int target) * This list is duplicated in both /fsm.h and /fsm/dispatch * * * * * * * * - S O U R C E - * * * * * * */ - || source == 16 + && source == 0 /* * * * * * * - T A R G E T - * * * * * * * * This list is duplicated in both /fsm.h and /fsm/dispatch * * -* ANY 0 -* WIDGET -* BUTTON -* SCROLL -* GLAREA -* TEXT -* LABEL -* TREE -* EXPANDER -* TOPBAR -* -* AUTO_NOTIFICATION 80 -* -* FSM 90 +* ANY WIDGET BUTTON SCROLL GLAREA TEXT LABEL TREE +* EXPANDER TOPBAR +* AUTO_NOTIFICATION +* FSM * * * This list is duplicated in both /fsm.h and /fsm/dispatch * * * * * * * * - T A R G E T - * * * * * * */ - || target == 41) + && target == 0) fsm_journal_push (message); } @@ -132,21 +122,21 @@ void fsm_init (char *initial_message_from_main) fsm_journal_init (&gg_logs); fsm_journal_event (initial_message_from_main, MESSAGE, SOURCE, TARGET); - fsm_journal_event ("fsm/dispatch initialisation fsm has began", MESSAGE, SOURCE, TARGET); + fsm_journal_event ("fsm/dispatch fsm initialisation has began", MESSAGE, SOURCE, TARGET); - fsm_measures_list_init(); fsm_journal_event ("fsm/dispatch measures list init()", MESSAGE, SOURCE, TARGET); + fsm_measures_list_init(); - fsm_results_list_init(); fsm_journal_event ("fsm/dispatch results list init()", MESSAGE, SOURCE, TARGET); + fsm_results_list_init(); - fsm_displayable_list_init(); fsm_journal_event ("fsm/dispatch displayable list init()", MESSAGE, SOURCE, TARGET); + fsm_displayable_list_init(); - fsm_preferences_list_init(); fsm_journal_event ("fsm/dispatch preferences list init()", MESSAGE, SOURCE, TARGET); + fsm_preferences_list_init(); - fsm_journal_event ("fsm/dispatch initialisation fsm has ended", MESSAGE, SOURCE, TARGET); + fsm_journal_event ("fsm/dispatch fsm initialisation has ended", MESSAGE, SOURCE, TARGET); } @@ -163,8 +153,8 @@ void fsm_set_preferences_modified (bool value) char str2[20]; sprintf(str2, " (%d)\n", value); strcat(str1, str2); fsm_journal_event (str1, INFO, SOURCE, TARGET); - fsm_journal_event ("fsm/dispatch preferences modified value = ?\n\ - > Je ne sais ni concatener les strings ni utiliser 'itoa'", INFO, SOURCE, TARGET); + fsm_journal_event ("fsm/dispatch preferences modified value = ?", + INFO, SOURCE, TARGET); preferences_have_been_modified = value; /* if (value) fsm_journal_event ( diff --git a/src/fsm/prefer.c b/src/fsm/prefer.c index 02a61e7..11f4a7e 100644 --- a/src/fsm/prefer.c +++ b/src/fsm/prefer.c @@ -136,11 +136,11 @@ void fsm_add_displayable (char *displayable_name) /******************************************************************************/ void fsm_preferences_list_init () { - fsm_journal_event ("fsm/prefer preferences list required()", MESSAGE, SOURCE, TARGET); + fsm_journal_event ("fsm/prefer setting up preferences list", MESSAGE, SOURCE, TARGET); } void fsm_displayable_list_init () { - fsm_journal_event ("fsm/prefer displayable list required()", MESSAGE, SOURCE, TARGET); + fsm_journal_event ("fsm/prefer setting up displayable list", MESSAGE, SOURCE, TARGET); } diff --git a/src/main.c b/src/main.c index 67a0c15..499dec0 100644 --- a/src/main.c +++ b/src/main.c @@ -140,8 +140,8 @@ int main (int argc, char **argv) GtkApplication *app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS); - fsm_journal_event ("main \ - g signal connect (app <--> on_windows_startup)", INFO, MAIN, WIDGETS); + fsm_journal_event ("main \ + g signal connect (app <--> on_windows_startup)", INFO, MAIN, WIDGETS); // ! WARNING ! 'on_windows_activation()' // and 'on_windows_startup()' are in: src/widget/dispatch.c // NOT in: src/signal.c diff --git a/src/signal.c b/src/signal.c index 1b9438f..26de06e 100644 --- a/src/signal.c +++ b/src/signal.c @@ -274,8 +274,8 @@ void on_toggle_exec_edit (GtkWidget *toggled_button, gpointer user_data) static void switch_state_rules_data() { - fsm_journal_event ("signal switch state rules data() has began", - INFO, SOURCE, TARGET); + fsm_journal_event ("signal switch state rules data()", + DEBUG, SOURCE, TARGET); switch (fsm_get_state_rules_data()) { case (SYNTH) : @@ -322,8 +322,6 @@ static void switch_state_rules_data() fsm_journal_event ("signal default in : switch state rules data()", INFO, SOURCE, TARGET); } - fsm_journal_event ("signal switch state rules data() has ended", - INFO, SOURCE, TARGET); } // TODO Il doit y avoir plus élégant,... ET SURTOUT MOINS DANGEREUX !!!