diary

Text-based journaling program
git clone https://git.in0rdr.ch/diary.git
Log | Files | Refs | README | LICENSE

commit cb8fa8947d3d715c59e350fc16b74117642278f2
parent 5928abacca520b1c45e0016a45b26a1d09fbf286
Author: Andreas Gruhler <agruhl@gmx.ch>
Date:   Sun, 26 Jun 2022 21:33:47 +0200

feat(lttng): replace more stderr logs with tracepoints

Diffstat:
Msrc/diary-tp.h | 14+++++++-------
Msrc/diary.c | 13++++++-------
Msrc/utils.c | 2+-
3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/src/diary-tp.h b/src/diary-tp.h @@ -30,25 +30,25 @@ TRACEPOINT_EVENT( TRACEPOINT_EVENT( diary, - debug, + error_date, TP_ARGS( - char*, msg_arg + char*, msg_arg, + const struct tm*, date_arg ), TP_FIELDS( ctf_string(msg, msg_arg) + ctf_string(date_arg, asctime(date_arg)) ) ) TRACEPOINT_EVENT( diary, - debug_date, + debug, TP_ARGS( - char*, msg_arg, - const struct tm*, date_arg + char*, msg_arg ), TP_FIELDS( ctf_string(msg, msg_arg) - ctf_string(date_arg, asctime(date_arg)) ) ) @@ -71,8 +71,8 @@ TRACEPOINT_EVENT( // TRACE_INFO // TRACE_DEBUG_LINE (default) TRACEPOINT_LOGLEVEL(diary, error, TRACE_ERR) +TRACEPOINT_LOGLEVEL(diary, error_date, TRACE_ERR) TRACEPOINT_LOGLEVEL(diary, debug, TRACE_DEBUG) -TRACEPOINT_LOGLEVEL(diary, debug_date, TRACE_DEBUG) TRACEPOINT_LOGLEVEL(diary, warning_2strings, TRACE_WARNING) #endif /* _DIARY_TP_H */ diff --git a/src/diary.c b/src/diary.c @@ -115,7 +115,7 @@ void display_entry(const char* dir, size_t dir_size, const struct tm* date, WIND // get entry path fpath(dir, dir_size, date, &ppath, sizeof path); if (ppath == NULL) { - fprintf(stderr, "Error while retrieving file path for diary reading"); + tracepoint(diary, error_date, "Cannot get file path for entry", date); return; } @@ -233,7 +233,7 @@ void display_entry(const char* dir, size_t dir_size, const struct tm* date, WIND void edit_cmd(const char* dir, size_t dir_size, const struct tm* date, char** rcmd, size_t rcmd_size) { // set the edit command to env editor if (strlen(CONFIG.editor) + 2 > rcmd_size) { - fprintf(stderr, "Binary path of default editor too long"); + tracepoint(diary, error, "Binary path of default editor too long"); *rcmd = NULL; return; } @@ -246,14 +246,14 @@ void edit_cmd(const char* dir, size_t dir_size, const struct tm* date, char** rc fpath(dir, dir_size, date, &ppath, sizeof path); if (ppath == NULL) { - fprintf(stderr, "Error while retrieving file path for editing"); + tracepoint(diary, error_date, "Cannot get file path for entry", date); *rcmd = NULL; return; } // concatenate editor command with entry path if (strlen(*rcmd) + strlen(path) + 1 > rcmd_size) { - fprintf(stderr, "Edit command too long"); + tracepoint(diary, error, "Edit command too long"); return; } strcat(*rcmd, path); @@ -507,7 +507,6 @@ int main(int argc, char** argv) { break; case 'w': // set first week day from option character - fprintf(stderr, "%i\n", atoi(optarg)); CONFIG.weekday = atoi(optarg); break; case 'f': @@ -760,7 +759,7 @@ int main(int argc, char** argv) { // get file path of entry and delete entry fpath(CONFIG.dir, diary_dir_size, &curs_date, &ppth, sizeof pth); if (ppth == NULL) { - tracepoint(diary, debug_date, "Error retrieving file path for entry", &curs_date); + tracepoint(diary, error_date, "Cannot get file path for entry", &curs_date); break; } @@ -797,7 +796,7 @@ int main(int argc, char** argv) { case 'e': case '\n': if (pecmd == NULL) { - fprintf(stderr, "Error retrieving edit command"); + tracepoint(diary, error, "Error retrieving edit command"); break; } diff --git a/src/utils.c b/src/utils.c @@ -20,7 +20,7 @@ bool date_has_entry(const char* dir, size_t dir_size, const struct tm* i) { fpath(dir, dir_size, i, &pepath, sizeof epath); if (pepath == NULL) { - tracepoint(diary, debug_date, "Error retrieving file path for entry", i); + tracepoint(diary, error_date, "Cannot get file path for entry", i); return false; }