MME2 changes - Propped commits from openmme/paging branch. Added scripts
for code gen
Change-Id: Ie55032217232214ac8544ca76ea34335205329e4
diff --git a/src/common/log.c b/src/common/log.c
new file mode 100644
index 0000000..cad7e36
--- /dev/null
+++ b/src/common/log.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd.
+ * Copyright (c) 2017 Intel Corporation
+ * Copyright (c) 2019, Infosys Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <time.h>
+#include <stdbool.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include "log.h"
+#include <sys/syscall.h>
+
+bool g_nolog = false;
+enum log_levels g_log_level = LOG_INFO;
+
+int pid = 0;
+char processName[255] = {0};
+
+static const char *log_level_name[] = { "INFO", "DEBUG", "WARN", "ERROR" };
+
+void log_message(int l, const char *file, int line, const char *fmt, ...)
+{
+ va_list arg;
+ if (g_nolog) return;
+ if(g_log_level > l) return;
+
+ FILE *fp = fopen("/tmp/mmelogs.txt", "a+");
+ if (fp == NULL)
+ {
+ printf("Could not open log file");
+ exit(0);
+ }
+
+ fprintf(fp,"%s(%d:%ld):%s-%s:%d:", processName, pid, syscall(SYS_gettid), log_level_name[l], file, line);
+ va_start(arg, fmt);
+// vfprintf(stderr, fmt, arg);
+ vfprintf(fp, fmt, arg);
+ va_end(arg);
+ fclose(fp);
+// fprintf(stderr, "\n");
+}
+