diff options
Diffstat (limited to 'libsylph')
-rw-r--r-- | libsylph/utils.c | 17 | ||||
-rw-r--r-- | libsylph/utils.h | 3 |
2 files changed, 20 insertions, 0 deletions
diff --git a/libsylph/utils.c b/libsylph/utils.c index 0ddae386..579edee7 100644 --- a/libsylph/utils.c +++ b/libsylph/utils.c @@ -3402,6 +3402,23 @@ void status_print(const gchar *format, ...) #define TIME_LEN 11 +void log_write(const gchar *str, const gchar *prefix) +{ + if (log_fp) { + gchar buf[TIME_LEN + 1]; + time_t t; + + time(&t); + strftime(buf, TIME_LEN + 1, "[%H:%M:%S] ", localtime(&t)); + + fputs(buf, log_fp); + if (prefix) + fputs(prefix, log_fp); + fputs(str, log_fp); + fflush(log_fp); + } +} + void log_print(const gchar *format, ...) { va_list args; diff --git a/libsylph/utils.h b/libsylph/utils.h index 7796541b..311525b0 100644 --- a/libsylph/utils.h +++ b/libsylph/utils.h @@ -476,6 +476,9 @@ void set_log_show_status_func (LogFunc status_func); void debug_print (const gchar *format, ...) G_GNUC_PRINTF(1, 2); void status_print (const gchar *format, ...) G_GNUC_PRINTF(1, 2); +void log_write (const gchar *str, + const gchar *prefix); + void log_print (const gchar *format, ...) G_GNUC_PRINTF(1, 2); void log_message (const gchar *format, ...) G_GNUC_PRINTF(1, 2); void log_warning (const gchar *format, ...) G_GNUC_PRINTF(1, 2); |