src/fsm/log/* functional log prototype
Each line of the log contains five items of information: [date - rank - source file - source function - value] It is mandatory for any event to call src/fsm/log/manager/fsm_add_log() to be published in the journal. fsm_add_log() can filter the informations according to their nature or severity. It then calls src/fsm/log/oper/fsm_add_log_event() to add the formatted line it produces. In include/fsm.h are: fsm_enum_log_severity and fsm_enum_log_source Four additional functions enable to initiate and close the log: in src/fsm/log/manager.c: fsm_trigger_log_init() and fsm_trigger_log_publication() in src/fsm/log/oper.c: fsm_init_log() and fsm_publish_log() Some functions that a typical list should implement but whose utility remains to evaluate in the case of a log list are in src/fsm/log/forget.c
This commit is contained in:
parent
6ad04de2c6
commit
e3e1a2006d
|
@ -0,0 +1,187 @@
|
|||
/**
|
||||
* @file
|
||||
* FSM (Finite State Machine) header
|
||||
*
|
||||
* This file is part of Gem-graph.
|
||||
*
|
||||
* In this commit, the fsm treats only the log.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* The production of the log requires: five structures, two enums, four
|
||||
* types and seven functions (see details below; the four macros are arbitrary)
|
||||
*
|
||||
* The role of the "severity" and "source" enumerations is to provide usable tools
|
||||
* for tagging messages so that they can be filtered.
|
||||
*
|
||||
* All logs must contain an item from each of these two enumerations.
|
||||
*
|
||||
* The filter is in fsm_add_log(). It uses the selected items as a labels to
|
||||
* highlight marked functions or structures during an inspection or repair.
|
||||
*
|
||||
* Only one message per function should be sent to the log, unless the function
|
||||
* generates several other functions of interest.
|
||||
*
|
||||
* If there are two messages or more in the same function, they should have the
|
||||
* same values from the enumerations 'severity' and 'source'.
|
||||
*
|
||||
*--
|
||||
*
|
||||
* @cond LICENSE
|
||||
* Copyright © 2021 Libre en Communs <contact@a-lec.org>
|
||||
* Copyright © 2021-2024 Adrien Bourmault <neox@a-lec.org>
|
||||
* Copyright © 2021-2024 Jean Sirmai <jean@a-lec.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
#include <gtk-4.0/gtk/gtk.h>
|
||||
|
||||
/******************************************************************************/
|
||||
/* J O U R N A L */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* The 'severity' enum conforms to canonical log levels:
|
||||
* FATAL, ERROR, WARN, INFO, DEBUG, TRACE
|
||||
*
|
||||
* https://betterstack.com/community/guides/logging/logging-best-practices/
|
||||
* https://en.wikipedia.org/wiki/Syslog
|
||||
*
|
||||
* All logs must contain at least one item from this enum and only one.
|
||||
* This item can not be set to NULL.
|
||||
*
|
||||
* @see fsm_add_log()
|
||||
*/
|
||||
enum fsm_enum_log_severity {
|
||||
FATAL, /**< (or CRITICAL) an unrecoverable failure that prevents the whole
|
||||
application from doing any further useful work */
|
||||
ERROR, /**< an irremediable situation that hinders the execution of a
|
||||
specific operation within the application */
|
||||
WARN, /**< something unexpected has occurred, but the application can
|
||||
continue to function normally for the time being */
|
||||
INFO, /**< (or MESSAGE) a significant event occurs while the system is
|
||||
operating normally */
|
||||
DEBUG, /**< a description of system states in sufficient detail to give
|
||||
developers clues as to the cause of an error */
|
||||
TRACE /**< provides a systematic overview of code execution but comes at
|
||||
a cost in terms of performance */
|
||||
};
|
||||
|
||||
/**
|
||||
* A list of structures that may be involved in a program event.
|
||||
*
|
||||
* All logs must contain at least one item from this enum and only one.
|
||||
* This item can be set to NULL.
|
||||
*
|
||||
* Only the main items of this list are commented on today. Further comments
|
||||
* will depend on its usage and structure which are just beginning to evolve.
|
||||
*
|
||||
* @see documentation
|
||||
* @see fsm_add_log()
|
||||
*/
|
||||
enum fsm_enum_log_source {
|
||||
AUTO_NOTIFICATION, /**< Not a source but a means of expression */
|
||||
DESTINATION, /**< SOURCE, TARGET */ SOURCE, TARGET,
|
||||
FSM_CONTENT, /**< LOG, FSM, PREFER */ LOG, FSM, PREFER,
|
||||
SRC_CONTENT, /**< MAIN, APP, WIDGETS, SIGNAL */ MAIN, APP, WIDGETS, SIGNAL,
|
||||
WINDOW, /**< MAIN, DIALOG, MODAL, TEXT */ DIALOG_WINDOW, MODAL_WINDOW,
|
||||
TEXT_WINDOW,
|
||||
TOPBAR, /**< LEFT, CENTER, RIGHT */ TOPBAR_LEFT, TOPBAR_CENTER, TOPBAR_RIGHT,
|
||||
PAGE, /**< SYNTH, STATE, RULES, MEASURES, RESULTS
|
||||
* \n RULES_PAGE == USER TREE versus SELECTED (vertical separation)*/
|
||||
SYNTH_PAGE, STATE_PAGE, RULES_PAGE, MEASURES_PAGE, RESULTS_PAGE,
|
||||
SYNTHESIS, /**< In the SYNTH page can be:
|
||||
* GLAREA, RESULTS (all), TIME_DEP_RESULTS, TIME_INDEP_RESULTS */
|
||||
SYNTH_GLAREA, SYNTH_ALL_RESULTS,
|
||||
SYNTH_TIME_DEP_RESULTS, SYNTH_TIME_INDEP_RESULTS,
|
||||
STATE_VIEW, /**< TOP, BOTTOM, GLAREA, CAMERA */
|
||||
STATE_TOP, STATE_BOTTOM, STATE_GLAREA, STATE_CAMERA,
|
||||
SINGLE_RULE_VIEW, /** GEOMETRY, GLAREA, CAMERA, ALGEBRA, CONDITION, ASSIGN,
|
||||
* ID, */
|
||||
RULE_GEOMETRY, RULE_GLAREA, RULE_CAMERA,
|
||||
RULE_ALGEBRA, RULE_CONDITION, RULE_ASSIGN, RULE_ID,
|
||||
TREE_RULES_VIEW, /** TREE, COMPARE, USE, */ RULES_TREE, RULES_COMPARE,
|
||||
RULES_USE,
|
||||
MEASURES_VIEW, /**< TOOLS, ACTIVITY, DISPLAY */
|
||||
MEASURES_TOOLS, MEASURES_ACTIVITY, MEASURES_DISPLAY,
|
||||
RESULTS_VIEW, /** TIME_DEP, TIME_INDEP */ TIME_DEP_RESULTS, TIME_INDEP_RESULTS,
|
||||
GTK_WIDGETS, /**< Only the main groups of widgets are mentioned here. */
|
||||
WIDGET, BUTTON, SCROLL, GLAREA, TEXT, LABEL, TREE, SLIDER, EXPANDER, ENTRY,
|
||||
OTHERS, /**< Experimental area */ ON_SWITCH_EXEC_EDIT, ON_SWITCH_STATE_RULES_DATA,
|
||||
SLIDER_X, SLIDER_Y, SLIDER_Z, SLIDER_A, SLIDER_B, SLIDER_C,
|
||||
};
|
||||
|
||||
/**
|
||||
* structure of a log element
|
||||
*
|
||||
* @callergraph
|
||||
* @see fsm_add_log()
|
||||
* @see fsm_add_log_event()
|
||||
*/
|
||||
typedef struct fsm_log_struct_unit
|
||||
{
|
||||
long yy_dd_mm; /**< * date of the event reported in the log */
|
||||
long usec; /**< * with microseconds precision */
|
||||
const char *file_source; /**< * emitter file */
|
||||
const char *function_source; /**< * emitter function */
|
||||
const char *string_value; /**< * any event descriptors */
|
||||
struct fsm_log_struct_unit *prev; /**< * chained list */
|
||||
struct fsm_log_struct_unit *next; /**< * chained list */
|
||||
}
|
||||
fsm_log_struct_unit;
|
||||
|
||||
|
||||
/**
|
||||
* required to initialise a double-chained list
|
||||
*
|
||||
* @see use in src/fsm/dispatch/fsm_add_log()
|
||||
* @see use in src/log/fsm_init_log()
|
||||
*/
|
||||
typedef struct {
|
||||
fsm_log_struct_unit *first; /**< * required */
|
||||
fsm_log_struct_unit *last; /**< * required */
|
||||
}
|
||||
fsm_log_struct;
|
||||
|
||||
void fsm_publish_log (fsm_log_struct jj);
|
||||
void fsm_init_log (fsm_log_struct *jj);
|
||||
void fsm_add_log_event (fsm_log_struct *jj,
|
||||
const char *file_source,
|
||||
const char *function_source,
|
||||
const char *string_value);
|
||||
long fsm_pop_back_log (fsm_log_struct *jj,
|
||||
const char *file_source,
|
||||
const char *function_source,
|
||||
const char *string_value);
|
||||
int fsm_get_log_length (fsm_log_struct jj);
|
||||
void fsm_seek_log (fsm_log_struct jj,
|
||||
long usec,
|
||||
const char *file_source,
|
||||
const char *function_source,
|
||||
const char *string_value);
|
||||
|
||||
void fsm_trigger_log_init();
|
||||
void fsm_trigger_log_publication();
|
||||
void fsm_add_log (int severity,
|
||||
int source,
|
||||
const char *file_source,
|
||||
const char *function_source,
|
||||
const char *string_value);
|
||||
|
||||
void fsm_init (char *message); // def: fsm/dispatch; call: main;
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
/**
|
||||
* @file
|
||||
* @brief fsm (Finite State Machine) tasks dispatcher
|
||||
*
|
||||
* This file is part of Gem-graph.
|
||||
*
|
||||
* @details
|
||||
* The Finite State Machine (fsm) describes all the possible states of the
|
||||
* Gem-graph client and all the transitions between them.
|
||||
* It manages several kinds of exclusive states:
|
||||
* - Run the model or edit it.
|
||||
* - Select a single view of the model from all those possible.
|
||||
* The different views show either the space, or the rule tree,
|
||||
* or a single rule of interest, or measurements or results.
|
||||
* NB an overview is possible, but it does not provide details.
|
||||
* - Apply a selected measurement to the currently running model
|
||||
* - Select some results for study or/and presentation.
|
||||
* - Choose the user's preferred values for a set of parameters
|
||||
* used to modify the appearance or behaviour of gem-graph.
|
||||
*
|
||||
* Each state of the fsm is a combination of each of these states.
|
||||
*
|
||||
* The current state of the fsm must be
|
||||
* - saved at the end of a work session and
|
||||
* - reread (available to the user) at the start of a new session.
|
||||
*
|
||||
* No state of the fsm should be defined in another module.
|
||||
*
|
||||
* No fsm transition should be executed in another module.
|
||||
*
|
||||
* The journal is created, edited and published from here.
|
||||
*
|
||||
* @cond LICENSE
|
||||
* Copyright © 2021 Libre en Communs <contact@a-lec.org>
|
||||
* Copyright © 2021-2024 Adrien Bourmault <neox@a-lec.org>
|
||||
* Copyright © 2021-2024 Jean Sirmai <jean@a-lec.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
|
||||
#include "../../include/fsm.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* OOOOOOOOOOO OOOOO OOO OOO *
|
||||
* OO OO OO OOOO OOOO *
|
||||
* OO OO OO OO OO OO *
|
||||
* OOOOOO OO OO OO OO OO *
|
||||
* OO OO OO OOO OO *
|
||||
* OO OO OO OO *
|
||||
* OO OO OOO OO OO *
|
||||
* OO OOOOOO OO OO *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* F S M I N I T *
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief fsm_init() is the first function called by main.c
|
||||
* It initiates the journal and the four lists:
|
||||
* 'measures', 'results', 'displayables results' and 'preferences'.
|
||||
* The items selected in these lists contribute to define the current
|
||||
* state of the fsm.
|
||||
*
|
||||
* @since 2024-08
|
||||
*
|
||||
* @callergraph
|
||||
* @see main()
|
||||
*
|
||||
* @callgraph
|
||||
* @see trigger_fsm_log_init()
|
||||
* @see fsm_add_log()
|
||||
* @see fsm_list_init_measures()
|
||||
* @see fsm_list_init_results()
|
||||
* @see fsm_list_init_displayables()
|
||||
* @see fsm_list_init_preferences()
|
||||
*
|
||||
* @param *initial_INFO_from_main
|
||||
*/
|
||||
void fsm_init (char *initial_INFO_from_main)
|
||||
{
|
||||
fsm_trigger_log_init();
|
||||
|
||||
fsm_add_log (INFO, MAIN, "main", initial_INFO_from_main, "👋️ (☕️)");
|
||||
|
||||
fsm_add_log (INFO, FSM, "fsm/dispatch", "fsm initialisation", "has began");
|
||||
/*
|
||||
* to reintroduce later on:
|
||||
|
||||
fsm_add_log (INFO, FSM, "fsm/dispatch", "measures list init()",
|
||||
"measurement processes");
|
||||
fsm_list_init_measures();
|
||||
|
||||
fsm_add_log (INFO, FSM, "fsm/dispatch", "results list init()",
|
||||
"measurement results (gross)");
|
||||
fsm_list_init_results();
|
||||
|
||||
fsm_add_log (INFO, FSM, "fsm/dispatch", "displayables list init()",
|
||||
"displayable results");
|
||||
fsm_list_init_displayables();
|
||||
|
||||
fsm_add_log (INFO, FSM, "fsm/dispatch", "preferences list init()",
|
||||
"preferences");
|
||||
fsm_list_init_preferences();
|
||||
*/
|
||||
fsm_add_log (INFO, FSM, "fsm/dispatch", "fsm initialisation", "has ended 😇️");
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* This file is part of Gem-graph. The log (or journal) stores chronologically
|
||||
* the events during a session run (rules exec, mainly)
|
||||
*
|
||||
* This file groups some functions that a typical list should implement but whose
|
||||
* utility remains to evaluate in the case of a log list.
|
||||
*
|
||||
* @cond LICENSE
|
||||
* Copyright © 2021 Libre en Communs <contact@a-lec.org>
|
||||
* Copyright © 2021-2024 Adrien Bourmault <neox@a-lec.org>
|
||||
* Copyright © 2021-2024 Jean Sirmai <jean@a-lec.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
#include "../../../include/fsm.h"
|
||||
|
||||
/**
|
||||
* remove an event
|
||||
*
|
||||
* @since 2024-09
|
||||
*
|
||||
* @param *jj
|
||||
* @param *file_source
|
||||
* @param *function_source
|
||||
* @param *string_value
|
||||
*/
|
||||
long fsm_pop_back_log (fsm_log_struct *jj,
|
||||
const char *file_source,
|
||||
const char *function_source,
|
||||
const char *string_value)
|
||||
{
|
||||
long usec;
|
||||
fsm_log_struct_unit *tmp = jj->last;
|
||||
if (! tmp) return -1;
|
||||
usec = tmp->usec;
|
||||
jj->last = tmp->prev;
|
||||
if (jj->last) jj->last->next = NULL;
|
||||
else jj->first = NULL;
|
||||
free (tmp);
|
||||
return usec; // retourne l'évènement retiré du journal.
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get journal_length
|
||||
*
|
||||
* @since 2024-09
|
||||
*
|
||||
* @param *jj
|
||||
* @return journal length
|
||||
*/
|
||||
int fsm_get_log_length (fsm_log_struct jj)
|
||||
{
|
||||
fsm_log_struct_unit *a_unit = jj.first;
|
||||
int nb = 0;
|
||||
while (a_unit)
|
||||
{
|
||||
nb ++;
|
||||
a_unit = a_unit->next;
|
||||
}
|
||||
// printf ("fsm journal length = %d\n", nb);
|
||||
return nb;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* seek for an event
|
||||
*
|
||||
* @since 2024-09
|
||||
*
|
||||
* @param *jj
|
||||
* @param usec
|
||||
* @param *file_source
|
||||
* @param *function_source
|
||||
* @param *string_value
|
||||
*/
|
||||
void fsm_seek_log (fsm_log_struct jj,
|
||||
long usec,
|
||||
const char *file_source,
|
||||
const char *function_source,
|
||||
const char *string_value)
|
||||
{
|
||||
fsm_log_struct_unit *a_unit = jj.first;
|
||||
int nb = 0;
|
||||
while (a_unit)
|
||||
{
|
||||
if (usec == a_unit->usec) nb++;
|
||||
a_unit = a_unit->next;
|
||||
}
|
||||
if (nb > 0) printf ("> date (usec) %ld found %d times in journal\n", usec, nb);
|
||||
else printf ("> date (usec) %ld not found in journal\n", usec);
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
/**
|
||||
* @file
|
||||
* @brief fsm (Finite State Machine) log manager
|
||||
*
|
||||
* This file is part of Gem-graph.
|
||||
*
|
||||
* @details
|
||||
* The Finite State Machine (fsm) describes all the possible states of the
|
||||
* Gem-graph client and all the transitions between them.
|
||||
*
|
||||
* In this commit, it manages only the log which is created, edited and published
|
||||
* from here.
|
||||
*
|
||||
* The current state of the fsm must be
|
||||
* - saved at the end of a work session and
|
||||
* - reread (available to the user) at the start of a new session.
|
||||
*
|
||||
* No state of the fsm should be defined in another module.
|
||||
*
|
||||
* No fsm transition should be executed in another module.
|
||||
*
|
||||
* @cond LICENSE
|
||||
* Copyright © 2021 Libre en Communs <contact@a-lec.org>
|
||||
* Copyright © 2021-2024 Adrien Bourmault <neox@a-lec.org>
|
||||
* Copyright © 2021-2024 Jean Sirmai <jean@a-lec.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
|
||||
#include "../../../include/fsm.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* J O U R N A L *
|
||||
*******************************************************************************/
|
||||
|
||||
/**
|
||||
* The fsm_struct_journal (gg_logs) is a static instance in this file.
|
||||
* Therefore, all the functions that read or write it are in this file.
|
||||
* This is to avoid uncontrolled operations on it.
|
||||
*/
|
||||
static fsm_log_struct gg_logs;
|
||||
|
||||
|
||||
/**
|
||||
* @brief This trigger is called only once, at the very beginning of the program;
|
||||
* the log is therefore initiated before any other event
|
||||
*
|
||||
* @since 2024-08
|
||||
*
|
||||
* @callgraph
|
||||
* @see fsm_init_log()
|
||||
* @callergraph
|
||||
* @see fsm_init()
|
||||
*/
|
||||
void fsm_trigger_log_init() {fsm_init_log (&gg_logs);}
|
||||
|
||||
|
||||
/**
|
||||
* @brief This trigger is called only once, just after closing the app and before
|
||||
* returning status to the system; this is to guarantee the chronological
|
||||
* order of the events.
|
||||
*
|
||||
* @details This is the last function of the program to be executed.
|
||||
* Just after its call, main() returns status.
|
||||
*
|
||||
* The log is modified for each event. As events can be send asynchronously,
|
||||
* the log is only published once, before the end of main().
|
||||
* Its chronological order is therefore guaranteed.
|
||||
*
|
||||
* @since 2024-08
|
||||
*
|
||||
* @callgraph
|
||||
* @see fsm_publish_log()
|
||||
* @callergraph
|
||||
* @see main()
|
||||
*/
|
||||
void fsm_trigger_log_publication() {fsm_publish_log (gg_logs);}
|
||||
|
||||
|
||||
/**
|
||||
* @brief It is mandatory for any event to call this function
|
||||
* to be published in the journal.
|
||||
*
|
||||
* @details The fsm_struct_journal (gg_logs) is a static instance in this file.
|
||||
* Therefore, all the functions that read or write it are in this file.
|
||||
* This is to avoid uncontrolled operations on it.
|
||||
*
|
||||
* A message is send to the log for each documented event.
|
||||
*
|
||||
* If there are too many events, one or several filters can be applied
|
||||
* here (and only here) before publication, to select only some events
|
||||
* of interest (during debugging, for example).
|
||||
*
|
||||
* These filters can operate on any the following five parameters:
|
||||
* severity, source, file_source (text), function_source (text),
|
||||
* string_value (text).
|
||||
*
|
||||
* They can be combined using any logical operators and parentheses.
|
||||
*
|
||||
* @since 2024-08
|
||||
*
|
||||
* @callgraph
|
||||
* @see fsm_add_log_event()
|
||||
*
|
||||
* @callergraph
|
||||
* @see fsm_init()
|
||||
*
|
||||
* @param severity: one of the following pre-defined values
|
||||
*
|
||||
* FATAL - ERROR - WARN - INFO - DEBUG - TRACE
|
||||
*
|
||||
* @param source: a pre-defined value (a name of a structure) that can be
|
||||
* associated to each event. It can be set to 'NULL'.
|
||||
*
|
||||
* @param *file_source the name of the file that emits the event
|
||||
* @param *function_source the function that emits the event
|
||||
* @param *string_value any value that better specifies the event
|
||||
*
|
||||
* @see fsm_enum_log_severity
|
||||
* @see fsm_enum_log_source
|
||||
*/
|
||||
void fsm_add_log (int severity,
|
||||
int source,
|
||||
const char *file_source,
|
||||
const char *function_source,
|
||||
const char *string_value)
|
||||
{
|
||||
if
|
||||
(
|
||||
severity < TRACE
|
||||
// && source == RULE_CONDITION
|
||||
)
|
||||
fsm_add_log_event (&gg_logs, file_source, function_source, string_value);
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* This file is part of Gem-graph. The log (or journal) stores chronologically
|
||||
* the events during a session run (rules exec, mainly)
|
||||
*
|
||||
* Today, the log presentation is;
|
||||
* [date - rank - source file - source function - value] ~
|
||||
* What types of events should be reported ? (fsm, widgets, ... )
|
||||
* How to name, classify and present it ?
|
||||
*
|
||||
*
|
||||
* @cond LICENSE
|
||||
* Copyright © 2021 Libre en Communs <contact@a-lec.org>
|
||||
* Copyright © 2021-2024 Adrien Bourmault <neox@a-lec.org>
|
||||
* Copyright © 2021-2024 Jean Sirmai <jean@a-lec.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
#include <sys/time.h>
|
||||
#include "../../../include/fsm.h"
|
||||
|
||||
#define LOG_MAX_LENGTH 255 /**< arbitrary TODO */
|
||||
|
||||
/**
|
||||
* init the journal
|
||||
*
|
||||
* @since 2024-09
|
||||
*
|
||||
* @param *jj
|
||||
*/
|
||||
void fsm_init_log (fsm_log_struct *jj)
|
||||
{
|
||||
jj->first = NULL;
|
||||
jj->last = NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* add an event
|
||||
*
|
||||
* @since 2024-09
|
||||
*
|
||||
* @param *jj
|
||||
* @param *file_source
|
||||
* @param *function_source
|
||||
* @param *string_value
|
||||
*/
|
||||
void fsm_add_log_event (fsm_log_struct *jj,
|
||||
const char *file_source,
|
||||
const char *function_source,
|
||||
const char *string_value)
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday (&tv, NULL);
|
||||
fsm_log_struct_unit *new_unit = malloc (sizeof(fsm_log_struct_unit));
|
||||
if (! new_unit) exit (EXIT_FAILURE);
|
||||
|
||||
new_unit->yy_dd_mm = tv.tv_sec;
|
||||
new_unit->usec = tv.tv_usec;
|
||||
new_unit->file_source = file_source;
|
||||
new_unit->function_source = function_source;
|
||||
new_unit->string_value = string_value;
|
||||
|
||||
new_unit->next = jj->first;
|
||||
new_unit->prev = NULL;
|
||||
if (jj->first) jj->first->prev = new_unit;
|
||||
else jj->last = new_unit;
|
||||
jj->first = new_unit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* publish all the logs
|
||||
* today just print in the console TODO > in a file
|
||||
*
|
||||
* @since 2024-09
|
||||
*
|
||||
* @param *jj
|
||||
*/
|
||||
void fsm_publish_log (fsm_log_struct jj)
|
||||
{
|
||||
fsm_log_struct_unit *a_unit = jj.last;
|
||||
char buf [LOG_MAX_LENGTH];
|
||||
int nb = 0;
|
||||
while (a_unit)
|
||||
{
|
||||
strftime(buf, sizeof(buf), "%D %T", localtime(&a_unit->yy_dd_mm));
|
||||
g_message ("%s + %-6ld %6d %-32s %-38s %-50s",
|
||||
buf,
|
||||
a_unit->usec,
|
||||
nb,
|
||||
a_unit->file_source,
|
||||
a_unit->function_source,
|
||||
a_unit->string_value);
|
||||
a_unit = a_unit->prev;
|
||||
nb ++;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* @file
|
||||
* Gem-graph-client fsm readme.dox file. (the .c extension is just crap)
|
||||
*
|
||||
* This file is part of Gem-graph.
|
||||
*
|
||||
* @cond LICENSE
|
||||
* Copyright © 2021 Libre en Communs <contact@a-lec.org>
|
||||
* Copyright © 2021-2024 Adrien Bourmault <neox@a-lec.org>
|
||||
* Copyright © 2021-2024 Jean Sirmai <jean@a-lec.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* @endcond
|
||||
*/
|
57
src/main.c
57
src/main.c
|
@ -1,9 +1,18 @@
|
|||
/**
|
||||
* @file
|
||||
* Gem-graph-client main file.
|
||||
*
|
||||
* Gem-graph main file
|
||||
* This file is part of Gem-graph. It contains only the main() function.
|
||||
*
|
||||
* This file is part of Gem-graph.
|
||||
* ---
|
||||
*
|
||||
* The main() function **initialises** the log, the finite state machine (fsm),
|
||||
* the application and the windows and **closes** all the elements it opened
|
||||
* before the end of program execution.
|
||||
*
|
||||
* About code organization, see src/readme.dox
|
||||
*
|
||||
* ---
|
||||
*
|
||||
* @cond LICENSE
|
||||
* Copyright © 2021 Libre en Communs <contact@a-lec.org>
|
||||
|
@ -25,18 +34,44 @@
|
|||
* @endcond
|
||||
*/
|
||||
|
||||
#include <gtk-4.0/gtk/gtk.h>
|
||||
#include "../include/fsm.h" // finite state machine (fsm) and log init
|
||||
|
||||
/**
|
||||
* @since 2024-04
|
||||
*
|
||||
* @callgraph
|
||||
* @see fsm_init() < defined in: src/fsm/dispatch
|
||||
*
|
||||
* @param argc
|
||||
* @param **argv
|
||||
* @return status, the program errorlevel
|
||||
*/
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
GtkApplication *app;
|
||||
int status;
|
||||
fsm_init ("first instruction / first log");
|
||||
|
||||
app = gtk_application_new ("org.jean.GTK4_GG_hack", G_APPLICATION_DEFAULT_FLAGS);
|
||||
//g_signal_connect (app, "activate", G_CALLBACK (on_main_window_activation), NULL);
|
||||
//g_signal_connect (app, "activate", G_CALLBACK (on_dialog_window_activation), NULL);
|
||||
status = g_application_run (G_APPLICATION (app), argc, argv);
|
||||
g_object_unref (app);
|
||||
fsm_add_log (INFO, MAIN, "main", "*app = gtk_application_new()",
|
||||
"| 👉️ trigger app initialization");
|
||||
GtkApplication *app = gtk_application_new ("org.gem-graph",
|
||||
G_APPLICATION_DEFAULT_FLAGS);
|
||||
|
||||
return status;
|
||||
fsm_add_log (INFO, MAIN, "main",
|
||||
"g signal connect (activate)",
|
||||
"| 👉️ windows creation requested");
|
||||
|
||||
// g_signal_connect (app, "startup", G_CALLBACK (on_windows_startup), NULL);
|
||||
// g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL);
|
||||
|
||||
fsm_add_log (INFO, MAIN, "main",
|
||||
"no g signal connect (activate)",
|
||||
"| 🖐️ windows creation denied");
|
||||
|
||||
int status = g_application_run (G_APPLICATION (app), argc, argv);
|
||||
fsm_add_log (INFO, MAIN, "main", "g_object unref (app)", "bye bye app !");
|
||||
g_object_unref (app);
|
||||
|
||||
fsm_add_log (INFO, MAIN, "main", "That'all folks !", "👋️😄️");
|
||||
fsm_trigger_log_publication();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* @file
|
||||
* @brief Gem-graph-client src readme.dox file (NB -> The .c extension is just crap).
|
||||
*
|
||||
* @details This file is part of Gem-graph.
|
||||
*
|
||||
* The code files are all located in the src (sources) directory
|
||||
* They are divided into several *types of organisation*:
|
||||
*
|
||||
* - *hierarchical*: the widgets that give the windows their appearance are
|
||||
* organised in the form of a tree.
|
||||
* Windows are the first level of depth.
|
||||
* Next come the title bars and the pages designed to occupy the windows
|
||||
* space below the title bars.
|
||||
* Each of these pages has its own hierarchical structure: it can be divided
|
||||
* into horizontal or vertical strips, which can themselves be divided in the
|
||||
* same way, with varying levels of depth right down to the last containers
|
||||
* which contain lists of widgets such as buttons, bars, entries or images.
|
||||
*
|
||||
* - *list*: the main *sections* of the fsm (finite state machine) constitute
|
||||
* a list of at least four elements, each of which defines a set of possible
|
||||
* states :
|
||||
* -# execute or edit (managing the appropriate tools states in both cases)
|
||||
* -# measure, operate on data, prepare displayable results
|
||||
* -# apply user preferences
|
||||
* -# indicate the desired state of windows and widgets
|
||||
* .
|
||||
* The state of the fsm is uniquely defined at all times by all the parameters
|
||||
* listed in these sections. All program actions depend on this state.
|
||||
*
|
||||
* - *transversal*: the other functions that must be easily accessible by all
|
||||
* the previous functions. They are therefore all located at the root.
|
||||
* These are the functions that manage graphics, callbacks, utilities, etc.
|
||||
*
|
||||
* ---
|
||||
*
|
||||
* @see
|
||||
* Model–view–controller || Model–view–viewmodel || Action–domain–responder ||
|
||||
* Multitier_architecture https://en.wikipedia.org/wiki/Multitier_architecture
|
||||
* (presentation, logic, data)
|
||||
*
|
||||
* @cond LICENSE
|
||||
* Copyright © 2021 Libre en Communs <contact@a-lec.org>
|
||||
* Copyright © 2021-2024 Adrien Bourmault <neox@a-lec.org>
|
||||
* Copyright © 2021-2024 Jean Sirmai <jean@a-lec.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero General Public License as published by the Free
|
||||
* Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* @endcond
|
||||
*/
|
Loading…
Reference in New Issue