Hello,
I wanted a timestamp to be printed in SD output, for correlating SD
events with other system activities. I made some changes in three files
and 'svn diff'-ed them as a patch (in attachment).
src/stored/stored.h:
- added 'dbg_timestamp' extern variable for indication if time needed in
output.
src/stored/stored.c:
- changed usage text - added '-dt' option to switch timestamps on
- changed usage text - changed '-dnn' to '-d <nn>'. <nn> is not treated
literally, but substituted, like <file> or <group>, I think.
- added procesing of 't' parameter when '-d' option is used.
src/lib/message.c:
- added 'dbg_timestamp' as a global variable.
- added code in 'd_msg' function to print date and time, when debugging
is on and 'dbg_timestamp' variable is set to 'true'.
Hope it could be useful for others :-)
Regards,
Mariusz Czulada
----------------------------------------------------
Walka o Mistrzostwo Świata! Krzysztof DIABLO Włodarczyk
20.10 po raz kolejny stanie ringu! Musisz to zobaczy!
Kliknij:
http://klik.wp.pl/?adr=http%3A%2F%2Fcorto.www.wp.pl%2Fas%2Folympic.html&sid=57
Index: src/stored/stored.c
===================================================================
--- src/stored/stored.c (wersja 5747)
+++ src/stored/stored.c (kopia robocza)
@@ -82,7 +82,8 @@
"\nVersion: %s (%s)\n\n"
"Usage: stored [options] [-c config_file] [config_file]\n"
" -c <file> use <file> as configuration file\n"
-" -dnn set debug level to nn\n"
+" -d<nn> set debug level to <nn>\n"
+" -dt print timestamp in debug output\n"
" -f run in foreground (for debugging)\n"
" -g <group> set groupid to group\n"
" -p proceed despite I/O errors\n"
@@ -142,9 +143,13 @@
break;
case 'd': /* debug level */
- debug_level = atoi(optarg);
- if (debug_level <= 0) {
- debug_level = 1;
+ if (*optarg == 't') {
+ dbg_timestamp = true;
+ } else {
+ debug_level = atoi(optarg);
+ if (debug_level <= 0) {
+ debug_level = 1;
+ }
}
break;
Index: src/stored/stored.h
===================================================================
--- src/stored/stored.h (wersja 5747)
+++ src/stored/stored.h (kopia robocza)
@@ -81,6 +81,7 @@
/* Daemon globals from stored.c */
extern STORES *me; /* "Global" daemon resource */
extern bool forge_on; /* proceed inspite of I/O errors */
+extern bool dbg_timestamp; /* print timestamp in debug output */
extern pthread_mutex_t device_release_mutex;
extern pthread_cond_t wait_device_release; /* wait for any device to be
released */
Index: src/lib/message.c
===================================================================
--- src/lib/message.c (wersja 5747)
+++ src/lib/message.c (kopia robocza)
@@ -50,6 +50,7 @@
const char *working_directory = NULL; /* working directory path stored
here */
int verbose = 0; /* increase User messages */
int debug_level = 1; /* debug level */
+bool dbg_timestamp = false; /* print timestamp in debug output */
time_t daemon_start_time = 0; /* Daemon start time */
const char *version = VERSION " (" BDATE ")";
char my_name[30]; /* daemon name is stored here */
@@ -843,6 +844,7 @@
int len;
va_list arg_ptr;
bool details = true;
+ time_t mtime;
if (level < 0) {
details = false;
@@ -850,6 +852,15 @@
}
if (level <= debug_level) {
+ if (dbg_timestamp) {
+ mtime = time(NULL);
+ bstrftimes(buf, sizeof(buf), mtime);
+ len = strlen(buf);
+ buf[len++] = ' ';
+ buf[len] = 0;
+ fputs(buf, stdout);
+ }
+
#ifdef FULL_LOCATION
if (details) {
len = bsnprintf(buf, sizeof(buf), "%s: %s:%d-%u ",
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bacula-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-devel