summaryrefslogtreecommitdiff
path: root/utils/log.h
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-05-29 16:18:18 +0100
committerVincent Sanders <vince@kyllikki.org>2015-05-29 16:18:18 +0100
commitfaf9b9d9196285d42bb106426b77e84baf3bfd6e (patch)
tree85048a826648a815b5fdf6bbd900f84004ea0783 /utils/log.h
parent4324bf535f4e65561bd48d78032edd4455f1579a (diff)
downloadnetsurf-faf9b9d9196285d42bb106426b77e84baf3bfd6e.tar.gz
netsurf-faf9b9d9196285d42bb106426b77e84baf3bfd6e.tar.bz2
Improve logging interface to reduce overhead
This reduces logging overhead by only calling the log output function once instead of three times. Additionally the nslog_gettime interface no longer needs to be exported and the static function is directly inlined further reducing function call overhead. Finally the appending of a newline uses fputc instead of a full printf call which is considerably more simple and further reduces overhead time.
Diffstat (limited to 'utils/log.h')
-rw-r--r--utils/log.h14
1 files changed, 2 insertions, 12 deletions
diff --git a/utils/log.h b/utils/log.h
index 1fd1415fd..708016b18 100644
--- a/utils/log.h
+++ b/utils/log.h
@@ -47,14 +47,7 @@ extern nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv);
# define LOG(format, ...) ((void) 0)
#else
-/**
- * Obtain a formatted string suitable for prepending to a log message
- *
- * \return formatted string of the time since first log call
- */
-extern const char *nslog_gettime(void);
-
-extern void nslog_log(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
+extern void nslog_log(const char *file, const char *func, int ln, const char *format, ...) __attribute__ ((format (printf, 4, 5)));
# ifdef __GNUC__
# define LOG_FN __PRETTY_FUNCTION__
@@ -70,10 +63,7 @@ extern void nslog_log(const char *format, ...) __attribute__ ((format (printf, 1
#define LOG(format, args...) \
do { \
if (verbose_log) { \
- nslog_log("%s " __FILE__ " %s %i: ", \
- nslog_gettime(), LOG_FN, LOG_LN); \
- nslog_log(format , ##args); \
- nslog_log("\n"); \
+ nslog_log(__FILE__, LOG_FN, LOG_LN, format , ##args); \
} \
} while(0)