Skip to content

Instantly share code, notes, and snippets.

@codingminecraft
Created March 21, 2021 20:25
Show Gist options
  • Save codingminecraft/62d88eddfd670dbef257fe173609d83a to your computer and use it in GitHub Desktop.
Save codingminecraft/62d88eddfd670dbef257fe173609d83a to your computer and use it in GitHub Desktop.
Simple Logger
@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
#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);
}
#pragma once
#define Log(str, ...) LogInternal(__FILE__, __LINE__, str, __VA_ARGS__)
void LogInternal(const char *file, int line, const char *format, ...);
#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