[libfann] 70/242: Added fann_set_error_log and supporting code
Christian Kastner
chrisk-guest at moszumanska.debian.org
Sat Oct 4 21:10:21 UTC 2014
This is an automated email from the git hooks/post-receive script.
chrisk-guest pushed a commit to tag Version2_0_0
in repository libfann.
commit 88b307a24a58428c8c7ff158784c08b973cfe409
Author: Evan Nemerson <evan at coeus-group.com>
Date: Tue Feb 10 07:27:30 2004 +0000
Added fann_set_error_log and supporting code
---
ChangeLog | 3 ++-
src/fann.c | 13 ++++++++++---
src/fann_internal.c | 10 +++++-----
src/include/fann.h | 4 ++++
src/include/fann_data.h | 5 +++++
5 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6fc021a..1b17dba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,4 @@
-libfann (1.0.6) stable; urgency=low
+libfann (1.1.0) stable; urgency=low
* Customize error output
* Error checking when allocating memory
* Debian package
@@ -9,6 +9,7 @@ libfann (1.0.6) stable; urgency=low
* Renamed fann_reset_error to fann_reset_MSE (keeping old one for now)
* Rearanged some code for easy access by the newly created fann php module
* Defined more activation functions and documented the old (in fann_activation.h)
+ * Added fann_set_error_log and supporting code
-- Steffen Nissen <lukesky at diku.dk>
diff --git a/src/fann.c b/src/fann.c
index 271ba2e..f1909af 100644
--- a/src/fann.c
+++ b/src/fann.c
@@ -1034,10 +1034,17 @@ char * fann_get_errstr(struct fann *ann)
return errstr;
}
-/* prints the last error to stderr
+/* change where errors are logged to
+ */
+void fann_set_error_log(struct fann *ann, FILE *log)
+{
+ ann->error_log = log;
+}
+
+/* prints the last error to the error log (default stderr)
*/
void fann_print_error(struct fann *ann) {
- if ( ann->errno_f != FANN_E_NO_ERROR ){
- fputs(ann->errstr, stderr);
+ if ( (ann->errno_f != FANN_E_NO_ERROR) && (ann->error_log != NULL) ){
+ fputs(ann->errstr, ann->error_log);
}
}
diff --git a/src/fann_internal.c b/src/fann_internal.c
index c466bec..efc4b4a 100644
--- a/src/fann_internal.c
+++ b/src/fann_internal.c
@@ -59,6 +59,7 @@ struct fann * fann_allocate_structure(float learning_rate, unsigned int num_laye
ann->error_value = 0;
ann->errstr = NULL;
ann->errno_f = 0;
+ ann->error_log = stderr;
#ifdef FIXEDFANN
/* these values are only boring defaults, and should really
@@ -645,7 +646,7 @@ void fann_error(struct fann *ann, const unsigned int errno, ...)
break;
case FANN_E_CANT_USE_ACTIVATION:
snprintf(errstr, FANN_ERRSTR_MAX, "Unable to use the selected activation function.\n");
- break;
+ break;
default:
vsnprintf(errstr, FANN_ERRSTR_MAX, "Unknown error.\n", ap);
break;
@@ -656,10 +657,9 @@ void fann_error(struct fann *ann, const unsigned int errno, ...)
fprintf(stderr, "FANN Error %d: %s", errno, errstr);
} else {
ann->errstr = errstr;
- /* TODO automaticly print to stderr if nothing else selected
- (other choices are file or just to keep them in the struct)
- */
- fprintf(stderr, "FANN Error %d: %s", errno, errstr);
+ if ( ann->error_log != NULL ) {
+ fprintf(ann->error_log, "FANN Error %d: %s", errno, errstr);
+ }
}
}
diff --git a/src/include/fann.h b/src/include/fann.h
index 7668d41..26e1000 100644
--- a/src/include/fann.h
+++ b/src/include/fann.h
@@ -277,6 +277,10 @@ void fann_reset_errno(struct fann *ann);
*/
void fann_reset_errstr(struct fann *ann);
+/* change where errors are logged to
+ */
+void fann_set_error_log(struct fann *ann, FILE *log);
+
/* returns the last error number
*/
unsigned int fann_get_errno(struct fann *ann);
diff --git a/src/include/fann_data.h b/src/include/fann_data.h
index 4397d1d..4ffa9a5 100644
--- a/src/include/fann_data.h
+++ b/src/include/fann_data.h
@@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef __fann_data_h__
#define __fann_data_h__
+#include <stdio.h>
+
/* ----- Data structures -----
* No data within these structures should be altered directly by the user.
*/
@@ -148,6 +150,9 @@ struct fann
/* The type of error that last occured. */
unsigned int errno_f;
+ /* Where to log error messages. */
+ FILE *error_log;
+
/* A string representation of the last error. */
char * errstr;
};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/libfann.git
More information about the debian-science-commits
mailing list