From 669f9c18142e50db3437b3cae46d4910df4b6c7f Mon Sep 17 00:00:00 2001 From: Dagen Brock Date: Fri, 28 Oct 2016 12:14:45 -0500 Subject: [PATCH] it helps to add the actual code for logging --- src/glog.c | 29 +++++++++++++++++++++++++++++ src/glog.h | 2 ++ 2 files changed, 31 insertions(+) create mode 100644 src/glog.c create mode 100644 src/glog.h diff --git a/src/glog.c b/src/glog.c new file mode 100644 index 0000000..efded3a --- /dev/null +++ b/src/glog.c @@ -0,0 +1,29 @@ +#include +#include + +int glog(char *s) { + time_t timer; + char buffer[26]; + struct tm* tm_info; + + time(&timer); + tm_info = localtime(&timer); + + strftime(buffer, 26, "%Y-%m-%d %H:%M:%S", tm_info); + printf("%s - %s\n", buffer, s); + + return 0; +} + +// only print partial, interim solution for not supporting printf style calling +void gloghead() { + time_t timer; + char buffer[26]; + struct tm* tm_info; + + time(&timer); + tm_info = localtime(&timer); + + strftime(buffer, 26, "%Y-%m-%d %H:%M:%S", tm_info); + printf("%s - ", buffer); +} diff --git a/src/glog.h b/src/glog.h new file mode 100644 index 0000000..b78f999 --- /dev/null +++ b/src/glog.h @@ -0,0 +1,2 @@ +int glog(char *s); +void gloghead();