Add option -l logfile to redirect diagnostic messages to a logfile rather
than stderr. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1179 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
4a1d97ff2a
commit
a305ac0143
|
@ -1,3 +1,9 @@
|
|||
2013-05-08 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
* main.c (main): Add option -l logfile.
|
||||
* avrdude.1: Document -l option.
|
||||
* doc/avrdude.texi: (Dito.)
|
||||
|
||||
2013-05-15 Rene Liebscher <R.Liebscher@gmx.de>
|
||||
|
||||
* configure.ac: if both found libftdi and libftdi1 use only libftdi1
|
||||
|
|
5
NEWS
5
NEWS
|
@ -129,6 +129,11 @@ Current:
|
|||
|
||||
(patch #7699 Read additional config files)
|
||||
|
||||
* The new option -l logfile allows to redirect diagnostic messages
|
||||
to a logfile rather than stdout. Useful to record debugging
|
||||
traces, in particular in environments which do not offer
|
||||
shell-style redirection functionality for standard streams.
|
||||
|
||||
* Programmer types in configuration file are no longer keywords but
|
||||
specified as string.
|
||||
|
||||
|
|
15
avrdude.1
15
avrdude.1
|
@ -1,6 +1,6 @@
|
|||
.\"
|
||||
.\" avrdude - A Downloader/Uploader for AVR device programmers
|
||||
.\" Copyright (C) 2001, 2002, 2003, 2005 - 2011 Joerg Wunsch
|
||||
.\" Copyright (C) 2001, 2002, 2003, 2005 - 2013 Joerg Wunsch
|
||||
.\"
|
||||
.\" This program is free software; you can redistribute it and/or modify
|
||||
.\" it under the terms of the GNU General Public License as published by
|
||||
|
@ -18,7 +18,7 @@
|
|||
.\"
|
||||
.\" $Id$
|
||||
.\"
|
||||
.Dd DATE December 3, 2012
|
||||
.Dd DATE May 16, 2013
|
||||
.Os
|
||||
.Dt AVRDUDE 1
|
||||
.Sh NAME
|
||||
|
@ -38,6 +38,7 @@
|
|||
.Oc
|
||||
.Op Fl F
|
||||
.Op Fl i Ar delay
|
||||
.Op Fl n logfile
|
||||
.Op Fl n
|
||||
.Op Fl O
|
||||
.Op Fl P Ar port
|
||||
|
@ -416,6 +417,16 @@ is running.
|
|||
On Win32 operating systems, a preconfigured number of cycles per
|
||||
microsecond is assumed that might be off a bit for very fast or very
|
||||
slow machines.
|
||||
.It Fl l Ar logfile
|
||||
Use
|
||||
.Ar logfile
|
||||
rather than
|
||||
.Va stderr
|
||||
for diagnostics output.
|
||||
Note that initial diagnostic messages (during option parsing) are still
|
||||
written to
|
||||
.Va stderr
|
||||
anyway.
|
||||
.It Fl n
|
||||
No-write - disables actually writing data to the MCU (useful for debugging
|
||||
.Nm avrdude
|
||||
|
|
|
@ -485,6 +485,11 @@ On Win32 operating systems, a preconfigured number of cycles per
|
|||
microsecond is assumed that might be off a bit for very fast or very
|
||||
slow machines.
|
||||
|
||||
@item -l @var{logfile}
|
||||
Use @var{logfile} rather than @var{stderr} for diagnostics output.
|
||||
Note that initial diagnostic messages (during option parsing) are still
|
||||
written to @var{stderr} anyway.
|
||||
|
||||
@item -n
|
||||
No-write - disables actually writing data to the MCU (useful for
|
||||
debugging AVRDUDE).
|
||||
|
|
20
main.c
20
main.c
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* avrdude - A Downloader/Uploader for AVR device programmers
|
||||
* Copyright (C) 2000-2005 Brian S. Dean <bsd@bsdhome.com>
|
||||
* Copyright 2007-2009 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
* Copyright 2007-2013 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -123,6 +123,7 @@ static void usage(void)
|
|||
" -Y <number> Initialize erase cycle # in EEPROM.\n"
|
||||
" -v Verbose output. -v -v for more.\n"
|
||||
" -q Quell progress output. -q -q for less.\n"
|
||||
" -l logfile Use logfile rather than stderr for diagnostics.\n"
|
||||
" -? Display this usage.\n"
|
||||
"\navrdude version %s, URL: <http://savannah.nongnu.org/projects/avrdude/>\n"
|
||||
,progname, version);
|
||||
|
@ -332,6 +333,7 @@ int main(int argc, char * argv [])
|
|||
int silentsafe; /* Don't ask about fuses, 1=silent, 0=normal */
|
||||
int init_ok; /* Device initialization worked well */
|
||||
int is_open; /* Device open succeeded */
|
||||
char * logfile; /* Use logfile rather than stderr for diagnostics */
|
||||
enum updateflags uflags = UF_AUTO_ERASE; /* Flags for do_op() */
|
||||
unsigned char safemode_lfuse = 0xff;
|
||||
unsigned char safemode_hfuse = 0xff;
|
||||
|
@ -411,6 +413,7 @@ int main(int argc, char * argv [])
|
|||
safemode = 1; /* Safemode on by default */
|
||||
silentsafe = 0; /* Ask by default */
|
||||
is_open = 0;
|
||||
logfile = NULL;
|
||||
|
||||
if (isatty(STDIN_FILENO) == 0)
|
||||
safemode = 0; /* Turn off safemode if this isn't a terminal */
|
||||
|
@ -459,7 +462,7 @@ int main(int argc, char * argv [])
|
|||
/*
|
||||
* process command line arguments
|
||||
*/
|
||||
while ((ch = getopt(argc,argv,"?b:B:c:C:DeE:Fi:np:OP:qstU:uvVx:yY:")) != -1) {
|
||||
while ((ch = getopt(argc,argv,"?b:B:c:C:DeE:Fi:l:np:OP:qstU:uvVx:yY:")) != -1) {
|
||||
|
||||
switch (ch) {
|
||||
case 'b': /* override default programmer baud rate */
|
||||
|
@ -519,6 +522,10 @@ int main(int argc, char * argv [])
|
|||
ovsigck = 1;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
logfile = optarg;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
uflags |= UF_NOWRITE;
|
||||
break;
|
||||
|
@ -608,6 +615,15 @@ int main(int argc, char * argv [])
|
|||
|
||||
}
|
||||
|
||||
if (logfile != NULL) {
|
||||
FILE *newstderr = freopen(logfile, "w", stderr);
|
||||
if (newstderr == NULL) {
|
||||
/* Help! There's no stderr to complain to anymore now. */
|
||||
printf("Cannot create logfile \"%s\": %s\n",
|
||||
logfile, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (quell_progress == 0) {
|
||||
if (isatty (STDERR_FILENO))
|
||||
|
|
Loading…
Reference in New Issue