Patch level : 12.0 nopatch
Files correlati : Commento : aggiunto un meccanismo di trace nei programmi Interno: Si attiva mettendo nel paragrafo Main di studio.ini TRACE = X
This commit is contained in:
parent
509d76607f
commit
0e9502d07d
@ -586,7 +586,15 @@ void TApplication::run(
|
|||||||
xvt_vobj_set_attr(NULL_WIN, ATTR_APPL_VERSION_STRING, (long)(const char*)ver);
|
xvt_vobj_set_attr(NULL_WIN, ATTR_APPL_VERSION_STRING, (long)(const char*)ver);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_xvt_hooks();
|
__set_trace();
|
||||||
|
|
||||||
|
const struct tm * timeloc = xvt_time_now();
|
||||||
|
|
||||||
|
TRACE("");
|
||||||
|
TRACE("----------");
|
||||||
|
TRACE("%s %s - %s %02d:%02d:%02d", argv[0], argv[1], today.string(), timeloc->tm_hour, timeloc->tm_min, timeloc->tm_sec);
|
||||||
|
TRACE("----------");
|
||||||
|
set_xvt_hooks();
|
||||||
|
|
||||||
_running = TRUE;
|
_running = TRUE;
|
||||||
xvt_app_create(argc, argv, 0L, task_eh, &cfg);
|
xvt_app_create(argc, argv, 0L, task_eh, &cfg);
|
||||||
|
@ -336,6 +336,12 @@ bool delete_box(const char* fmt, ...)
|
|||||||
return r == RESP_DEFAULT;
|
return r == RESP_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HIDDEN bool __traceon = false;
|
||||||
|
|
||||||
|
void __set_trace()
|
||||||
|
{
|
||||||
|
__traceon = ini_get_bool(CONFIG_STUDIO, "Main", "TRACE");
|
||||||
|
}
|
||||||
// @doc EXTERNAL
|
// @doc EXTERNAL
|
||||||
// @msg __trace | Permette di mandare dei messaggi nel file trace.log
|
// @msg __trace | Permette di mandare dei messaggi nel file trace.log
|
||||||
bool __trace(
|
bool __trace(
|
||||||
@ -347,21 +353,31 @@ bool __trace(
|
|||||||
//
|
//
|
||||||
// @rdesc Ritorna non 0 se riesca ad aprire il file trace.log
|
// @rdesc Ritorna non 0 se riesca ad aprire il file trace.log
|
||||||
{
|
{
|
||||||
static FILE* f = NULL;
|
static FILE* f = nullptr;
|
||||||
if (f == NULL)
|
|
||||||
fopen_s(&f, "trace.log", "w");
|
if (__traceon)
|
||||||
if (f != NULL)
|
{
|
||||||
{
|
if (f == nullptr)
|
||||||
buildmsg();
|
fopen_s(&f, "trace.log", "a");
|
||||||
fprintf(f, "%s\n", msg);
|
if (f != nullptr)
|
||||||
fflush(f);
|
{
|
||||||
}
|
buildmsg();
|
||||||
return f != NULL;
|
fprintf(f, "%s\n", msg);
|
||||||
|
fflush(f);
|
||||||
|
}
|
||||||
|
return f != NULL;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool __tracemem(const char* msg)
|
bool __tracemem(const char* msg)
|
||||||
{
|
{
|
||||||
unsigned long mem = xvt_sys_get_free_memory_kb();
|
if (__traceon)
|
||||||
return __trace("%5lu Kb - %s", mem, msg);
|
{
|
||||||
|
unsigned long mem = xvt_sys_get_free_memory_kb();
|
||||||
|
|
||||||
|
return __trace("%5lu Kb - %s", mem, msg);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ extern "C" {
|
|||||||
bool cantread_box(const char* filename);
|
bool cantread_box(const char* filename);
|
||||||
bool cantwrite_box(const char* filename);
|
bool cantwrite_box(const char* filename);
|
||||||
bool cantaccess_box(const char* filename);
|
bool cantaccess_box(const char* filename);
|
||||||
|
void __set_trace();
|
||||||
bool __trace(const char* fmt, ...);
|
bool __trace(const char* fmt, ...);
|
||||||
bool __tracemem(const char* fmt);
|
bool __tracemem(const char* fmt);
|
||||||
|
|
||||||
@ -105,15 +106,10 @@ extern "C" {
|
|||||||
|
|
||||||
// Utilizzata in fase di debug (definire il simbolo TRC in compilazione)
|
// Utilizzata in fase di debug (definire il simbolo TRC in compilazione)
|
||||||
|
|
||||||
#ifdef TRC
|
|
||||||
// @doc EXTERNAL
|
// @doc EXTERNAL
|
||||||
|
|
||||||
// @msg TRACE | Macro che richiama la funzione <m __trace>
|
// @msg TRACE | Macro che richiama la funzione <m __trace>
|
||||||
#define TRACE __trace
|
#define TRACE __trace
|
||||||
#define TRACEMEM(msg) __tracemem(msg)
|
#define TRACEMEM(msg) __tracemem(msg)
|
||||||
#else
|
|
||||||
#define TRACE 1 ? 0 : __trace
|
|
||||||
#define TRACEMEM(msg) 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // __CHECKS_H
|
#endif // __CHECKS_H
|
||||||
|
@ -139,6 +139,7 @@ bool TLog_report::log(int sev, const char* msg)
|
|||||||
{
|
{
|
||||||
TText_recordset* csv = (TText_recordset*)recordset();
|
TText_recordset* csv = (TText_recordset*)recordset();
|
||||||
bool ok = csv != NULL;
|
bool ok = csv != NULL;
|
||||||
|
TRACE("%d - %s", sev, msg);
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
//controlla se la stringa esiste gia'
|
//controlla se la stringa esiste gia'
|
||||||
|
@ -757,6 +757,7 @@ void execute_transactions(TArray & transactions, TLog_report & log, bool interac
|
|||||||
pref.rtrim(1);
|
pref.rtrim(1);
|
||||||
while (i >= 0)
|
while (i >= 0)
|
||||||
{
|
{
|
||||||
|
TRACE("Salvataggio registrazione %d", i);
|
||||||
if (t.executer() == table && t.name().starts_with(pref))
|
if (t.executer() == table && t.name().starts_with(pref))
|
||||||
{
|
{
|
||||||
t.write();
|
t.write();
|
||||||
@ -783,8 +784,10 @@ void execute_transactions(TArray & transactions, TLog_report & log, bool interac
|
|||||||
app << " -u" << user();
|
app << " -u" << user();
|
||||||
TExternal_app cmd(app);
|
TExternal_app cmd(app);
|
||||||
|
|
||||||
cmd.run();
|
TRACE("Aggiornamento registrazione %d", i);
|
||||||
|
cmd.run();
|
||||||
list_files(filemask, files);
|
list_files(filemask, files);
|
||||||
|
TRACE("Aggiornamneto log");
|
||||||
FOR_EACH_ARRAY_ROW(files, r, str)
|
FOR_EACH_ARRAY_ROW(files, r, str)
|
||||||
{
|
{
|
||||||
TTransaction t(*str);
|
TTransaction t(*str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user