Add debug time stamps via -Z and --debug-time-stamps

pull/11/head
Michael Black W9MDB 2018-04-14 17:20:28 -05:00 zatwierdzone przez Nate Bargmann
rodzic 841acdf011
commit 6c369109e6
11 zmienionych plików z 94 dodań i 7 usunięć

Wyświetl plik

@ -411,6 +411,10 @@ will use the verbose facility to print critical values useful for
testing and will often ask for this output in response to a request
for help.
@item -Z
@itemx --debug-time-stamps
Enable time stamps on debug output.
@item -h
@itemx --help
Show summary of these options and exit.
@ -421,6 +425,7 @@ Show summary of these options and exit.
@item -V
@itemx --version
Show version of @command{rigctl} and exit.
@end table
@quotation Note
@ -1414,6 +1419,10 @@ will use the verbose facility to print critical values useful for
testing and will often ask for this output in response to a request
for help.
@item -Z
@itemx --debug-time-stamps
Enable time stamps on debug output.
@item -h
@itemx --help
Show summary of these options and exit.
@ -1913,6 +1922,10 @@ will use the verbose facility to print critical values useful for
testing and will often ask for this output in response to a request
for help.
@item -Z
@itemx --debug_time_stamps
Enable time stamps on debug output.
@item -h
@itemx --help
Show summary of these options and exit.
@ -1923,6 +1936,7 @@ Show summary of these options and exit.
@item -V
@itemx --version
Show version of @command{rigctl} and exit.
@end table
@quotation Note
@ -2948,6 +2962,10 @@ will use the verbose facility to print critical values useful for
testing and will often ask for this output in response to a request
for help.
@item -Z
@itemx --debug-time-stamps
Enable time stamps on debug output.
@item -h
@itemx --help
Show summary of these options and exit.

Wyświetl plik

@ -2180,6 +2180,9 @@ rig_setting2idx HAMLIB_PARAMS((setting_t s));
extern HAMLIB_EXPORT(void)
rig_set_debug HAMLIB_PARAMS((enum rig_debug_level_e debug_level));
extern HAMLIB_EXPORT(void)
rig_set_debug_time_stamp HAMLIB_PARAMS((int flag));
#define rig_set_debug_level(level) rig_set_debug(level)
extern HAMLIB_EXPORT(int)

Wyświetl plik

@ -42,6 +42,7 @@
#include <errno.h> /* Error number definitions */
#include <sys/types.h>
#include <unistd.h>
#include <time.h>
#ifdef ANDROID
# include <android/log.h>
@ -54,6 +55,7 @@
static int rig_debug_level = RIG_DEBUG_TRACE;
static int rig_debug_time_stamp = 0;
static FILE *rig_debug_stream;
static vprintf_cb_t rig_vprintf_cb;
static rig_ptr_t rig_vprintf_arg;
@ -128,6 +130,30 @@ int HAMLIB_API rig_need_debug(enum rig_debug_level_e debug_level)
return (debug_level <= rig_debug_level);
}
/**
* \param debug_time_stamp
* \brief Enbable/disable time stamp on debug output
*/
void HAMLIB_API rig_set_debug_time_stamp(int flag)
{
rig_debug_time_stamp = flag;
}
char *date_strget(char *buf,int buflen)
{
time_t mytime;
struct tm *mytm;
struct timeval tv;
mytime=time(NULL);
mytm = gmtime(&mytime);
gettimeofday(&tv,NULL);
strftime(buf,buflen,"%Y-%m-%d:%H:%M:%S.",mytm);
char tmp[16];
sprintf(tmp,"%06ld",tv.tv_usec);
strcat(buf,tmp);
return buf;
}
/**
* \param debug_level
@ -157,7 +183,10 @@ void HAMLIB_API rig_debug(enum rig_debug_level_e debug_level,
{
rig_debug_stream = stderr;
}
if (rig_debug_time_stamp) {
char buf[256];
fprintf(rig_debug_stream,"%s: ",date_strget(buf,sizeof(buf)));
}
vfprintf(rig_debug_stream, fmt, ap);
fflush(rig_debug_stream);
}
@ -190,6 +219,10 @@ void HAMLIB_API rig_debug(enum rig_debug_level_e debug_level,
a = ANDROID_LOG_VERBOSE;
break;
case RIG_DEBUG_TIME:
a = ANDROID_LOG_VERBOSE;
break;
default:
a = ANDROID_LOG_DEBUG;
break;

Wyświetl plik

@ -151,11 +151,15 @@ is not set, the value of HOME is used.
.B \-v, --verbose
Set verbose mode, cumulative (see DIAGNOSTICS below).
.TP
.B \-Z, --debug-time-stamps
Enable time stamps for the debug messages
.TP
.B \-h, --help
Show summary of these options and exit.
.TP
.B \-V, --version
Show version of \fBrigctl\fP and exit.
.sp
.PP
\fBN.B.\fP Some options may not be implemented by a given backend and will
return an error. This is most likely to occur with the \fI\-\-set-conf\fP

Wyświetl plik

@ -87,7 +87,7 @@ void usage(void);
* NB: do NOT use -W since it's reserved by POSIX.
* TODO: add an option to read from a file
*/
#define SHORT_OPTIONS "+m:r:p:d:P:D:s:c:t:lC:LuonvhV"
#define SHORT_OPTIONS "+m:r:p:d:P:D:s:c:t:lC:LuonvhVZ"
static struct option long_options[] =
{
{"model", 1, 0, 'm'},
@ -105,6 +105,7 @@ static struct option long_options[] =
{"dump-caps", 0, 0, 'u'},
{"vfo", 0, 0, 'o'},
{"no-restore-ai", 0, 0, 'n'},
{"debug-time-stamps",0, 0, 'Z'},
#ifdef HAVE_READLINE_HISTORY
{"read-history", 0, 0, 'i'},
{"save-history", 0, 0, 'I'},
@ -399,6 +400,10 @@ int main(int argc, char *argv[])
dump_caps_opt++;
break;
case 'Z':
rig_set_debug_time_stamp(1);
break;
default:
usage(); /* unknown option? */
exit(1);
@ -636,6 +641,7 @@ void usage(void)
" -I, --save-history save current interactive session history\n"
#endif
" -v, --verbose set verbose mode, cumulative (-v to -vvvvv)\n"
" -Z, --debug-time-stamps enable time stamps for debug messages\n"
" -h, --help display this help and exit\n"
" -V, --version output version information and exit\n\n"
);

Wyświetl plik

@ -137,6 +137,9 @@ below.
.B \-v, --verbose
Set verbose mode, cumulative (see \fIDIAGNOSTICS\fP below).
.TP
.B \-Z, --debug-time-stamps
Enable time stamps for the debug messages
.TP
.B \-h, --help
Show a summary of these options and exit.
.TP

Wyświetl plik

@ -85,7 +85,7 @@
* NB: do NOT use -W since it's reserved by POSIX.
* TODO: add an option to read from a file
*/
#define SHORT_OPTIONS "m:r:p:d:P:D:s:c:T:t:C:lLuovhV"
#define SHORT_OPTIONS "m:r:p:d:P:D:s:c:T:t:C:lLuovhVZ"
static struct option long_options[] =
{
{"model", 1, 0, 'm'},
@ -106,6 +106,7 @@ static struct option long_options[] =
{"verbose", 0, 0, 'v'},
{"help", 0, 0, 'h'},
{"version", 0, 0, 'V'},
{"debug-time-stamps",0, 0, 'Z'},
{0, 0, 0, 0}
};
@ -929,7 +930,7 @@ void * handle_socket(void *arg)
{
retcode = 1;
}
if (retcode == 1)
if (retcode == 1)
{
retcode = rig_open(my_rig);
}
@ -1020,8 +1021,9 @@ void usage(void)
" -u, --dump-caps dump capabilities and exit\n"
" -o, --vfo do not default to VFO_CURR, require extra vfo arg\n"
" -v, --verbose set verbose mode, cumulative (-v to -vvvvv)\n"
" -Z, --debug-time-stamps enable time stamps for debug messages\n"
" -h, --help display this help and exit\n"
" -V, --version output version information and exit\n\n",
" -V, --version output version information and exit\n\n",
portno);
usage_rig(stdout);

Wyświetl plik

@ -110,6 +110,9 @@ is not set, the value of HOME is used.
.B \-v, --verbose
Set verbose mode, cumulative (see DIAGNOSTICS below).
.TP
.B \-Z, --debug-time-stamps
Enable time stamps for the debug messages
.TP
.B \-h, --help
Show summary of these options and exit.
.TP

Wyświetl plik

@ -82,7 +82,7 @@ void usage();
* NB: do NOT use -W since it's reserved by POSIX.
* TODO: add an option to read from a file
*/
#define SHORT_OPTIONS "+m:r:s:C:t:LvhVlu"
#define SHORT_OPTIONS "+m:r:s:C:t:LvhVluZ"
static struct option long_options[] =
{
{"model", 1, 0, 'm'},
@ -93,6 +93,7 @@ static struct option long_options[] =
{"set-conf", 1, 0, 'C'},
{"show-conf", 0, 0, 'L'},
{"dump-caps", 0, 0, 'u'},
{"debug-time-stamps",0,0, 'Z'},
#ifdef HAVE_READLINE_HISTORY
{"read-history", 0, 0, 'i'},
{"save-history", 0, 0, 'I'},
@ -258,6 +259,10 @@ int main(int argc, char *argv[])
dump_caps_opt++;
break;
case 'Z':
rig_set_debug_time_stamp(1);
break;
default:
usage(); /* unknown option? */
exit(1);
@ -460,6 +465,7 @@ void usage()
" -I, --save-history save current interactive session history\n"
#endif
" -v, --verbose set verbose mode, cumulative\n"
" -Z, --debug-time-stamps enable time stamps for debug messages\n"
" -h, --help display this help and exit\n"
" -V, --version output version information and exit\n\n"
);

Wyświetl plik

@ -109,6 +109,9 @@ Dump capabilities for the rotator defined with -m above and exit.
.B \-v, --verbose
Set verbose mode, cumulative (see DIAGNOSTICS below).
.TP
.B \-Z, --debug-time-stamps
Enable time stamps for the debug messages
.TP
.B \-h, --help
Show a summary of these options and exit.
.TP

Wyświetl plik

@ -84,7 +84,7 @@ void usage();
* NB: do NOT use -W since it's reserved by POSIX.
* TODO: add an option to read from a file
*/
#define SHORT_OPTIONS "m:r:s:C:t:T:LuvhVl"
#define SHORT_OPTIONS "m:r:s:C:t:T:LuvhVlZ"
static struct option long_options[] =
{
{"model", 1, 0, 'm'},
@ -96,6 +96,7 @@ static struct option long_options[] =
{"set-conf", 1, 0, 'C'},
{"show-conf", 0, 0, 'L'},
{"dump-caps", 0, 0, 'u'},
{"debug-time-stamps",0, 0, 'Z'},
{"verbose", 0, 0, 'v'},
{"help", 0, 0, 'h'},
{"version", 0, 0, 'V'},
@ -279,6 +280,10 @@ int main(int argc, char *argv[])
dump_caps_opt++;
break;
case 'Z':
rig_set_debug_time_stamp(1);
break;
default:
usage(); /* unknown option? */
exit(1);
@ -692,6 +697,7 @@ void usage()
" -l, --list list all model numbers and exit\n"
" -u, --dump-caps dump capabilities and exit\n"
" -v, --verbose set verbose mode, cumulative\n"
" -Z, --debug-time-stamps enable time stamps for debug messages\n"
" -h, --help display this help and exit\n"
" -V, --version output version information and exit\n\n",
portno);