aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2022-10-27 15:46:04 -0400
committerCara Salter <cara@devcara.com>2022-10-27 15:46:04 -0400
commitf500a9bae22516ac878c3c92bf1a2523102897e1 (patch)
treefbdc8528140ea749ad42add90982dd41fbb3515e /src
parentf0f0efcafeec83850add53712eb463c8ff5ee9be (diff)
downloadcmud-f500a9bae22516ac878c3c92bf1a2523102897e1.tar.gz
cmud-f500a9bae22516ac878c3c92bf1a2523102897e1.zip
autotools
Diffstat (limited to 'src')
-rw-r--r--src/log.c53
-rw-r--r--src/log.h23
-rw-r--r--src/main.c2
-rw-r--r--src/util.h1
4 files changed, 79 insertions, 0 deletions
diff --git a/src/log.c b/src/log.c
new file mode 100644
index 0000000..c6e2af2
--- /dev/null
+++ b/src/log.c
@@ -0,0 +1,53 @@
+/*
+ * =====================================================================================
+ *
+ * Filename: log.c
+ *
+ * Description: Implementations for logging framework
+ *
+ * Version: 1.0
+ * Created: 10/27/2022 10:02:48 AM
+ * Revision: none
+ * Compiler: gcc
+ *
+ * Author: Cara Salter (cara@devcara.com)
+ * Organization:
+ *
+ * =====================================================================================
+ */
+
+/* ##### HEADER FILE INCLUDES ################################################### */
+
+#include <stdlib.h>
+#include <time.h>
+
+
+/* ##### FUNCTION DEFINITIONS - LOCAL TO THIS SOURCE FILE ##################### */
+
+
+/*
+ * === FUNCTION ======================================================================
+ * Name: debug
+ * Description: Outputs debugging information to stdout
+ * =====================================================================================
+ */
+int debug(char msg[]) {
+ /* :TODO:10/27/2022 11:48:32 AM:: Fix time get */
+
+ time_t cur_time = time(NULL);
+ struct tm t = *localtime(&t);
+
+ printf("now: %d-%02d-%02d %02d:%02d:%02d\n", t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
+ return 0;
+}
+
+
+/*
+ * === FUNCTION ======================================================================
+ * Name: info
+ * Description: Outputs informational messages to stdout
+ * =====================================================================================
+ */
+int info(char msg[]) {
+ return 0;
+} /* ----- end of function info ----- */
diff --git a/src/log.h b/src/log.h
new file mode 100644
index 0000000..cf2fa3e
--- /dev/null
+++ b/src/log.h
@@ -0,0 +1,23 @@
+/*
+ * =====================================================================================
+ *
+ * Filename: log.h
+ *
+ * Description: Header file for logging framework
+ *
+ * Version: 1.0
+ * Created: 10/27/2022 09:56:57 AM
+ * Revision: none
+ * Compiler: gcc
+ *
+ * Author: Cara Salter (cara@devcara.com)
+ * Organization:
+ *
+ * =====================================================================================
+ */
+
+
+/* ##### EXPORTED FUNCTION DECLARATIONS ######################################### */
+ /* :TODO:10/27/2022 11:48:08 AM:: Sort out other levels */
+int debug(char msg[]);
+int info(char msg[]);
diff --git a/src/main.c b/src/main.c
index 551962b..c9ec18e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2,6 +2,7 @@
* Initializes main game loop and hands off to listeners
* */
#include "server.h"
+#include "log.h"
#include <stdlib.h>
#include <stdio.h>
@@ -14,6 +15,7 @@ int main() {
int err = 0;
server_t server = {0};
err = server_listen(&server);
+ debug("Test");
if (err) {
printf("Failed to listen on address");
return err;
diff --git a/src/util.h b/src/util.h
index 14fe005..de4f491 100644
--- a/src/util.h
+++ b/src/util.h
@@ -18,6 +18,7 @@
#include <ctype.h>
#include <string.h>
+#include "log.h"
char* trimwhitespace(char* str);