Created
March 21, 2021 20:25
-
-
Save codingminecraft/62d88eddfd670dbef257fe173609d83a to your computer and use it in GitHub Desktop.
Simple Logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
IF NOT EXIST bin mkdir bin | |
IF NOT EXIST bin-int mkdir bin-int | |
pushd bin-int | |
cl ..\main.cpp ..\Log.cpp /c /Wall /wd4189 | |
cl main.obj Log.obj /link /out:main.exe | |
popd | |
move bin-int\main.exe bin\main.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdarg.h> | |
#include "Log.h" | |
void LogInternal(const char *file, int line, const char *format, ...) | |
{ | |
printf("'%s' Line: %d\n", file, line); | |
printf("\t"); | |
va_list argptr; | |
va_start(argptr, format); | |
vprintf(format, argptr); | |
va_end(argptr); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#define Log(str, ...) LogInternal(__FILE__, __LINE__, str, __VA_ARGS__) | |
void LogInternal(const char *file, int line, const char *format, ...); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#include "Log.h" | |
int main() | |
{ | |
#ifdef WINDOWS | |
Log("This is a log. Here is a number %d", 10); | |
#endif | |
int myVariable = 30.0f; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment