As a first step to eliminating all the fprintfs in the library, make a logger function that just calls fprintf. This is a bit more complex than needed, because we want to do something more interesting with the formatted string in the future. --- lib/database.cc | 19 +++++++++++++++++++ lib/notmuch.h | 10 +++++++++- 2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/lib/database.cc b/lib/database.cc index 3601f9d..f3c62ee 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -916,6 +916,25 @@ notmuch_database_open (const char *path, return status; } +void +notmuch_database_log (notmuch_database_t *notmuch, + const char *format, + ...) +{ + va_list va_args; + const char *message; + + va_start (va_args, format); + + message = talloc_vasprintf (notmuch, format, va_args); + + /* XXX do something more clever here */ + fputs (message, stderr); + + talloc_free ((char *)message); + +} + notmuch_status_t notmuch_database_close (notmuch_database_t *notmuch) { diff --git a/lib/notmuch.h b/lib/notmuch.h index 220839b..c8c8124 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -279,7 +279,15 @@ notmuch_status_t notmuch_database_open (const char *path, notmuch_database_mode_t mode, notmuch_database_t **database); - +/** + * Log a message to where the database is configured to log it + * + * Initially this does notmuch interesting, since the output is not + * yet configurable. + */ +void +notmuch_database_log (notmuch_database_t *notmuch, + const char *format, ...); /** * Commit changes and close the given notmuch database. * -- 2.1.3