Reviewed custom logging functionality
This commit is contained in:
parent
9150b54b3e
commit
6f61e26a3c
2 changed files with 6 additions and 14 deletions
|
@ -2,17 +2,7 @@
|
||||||
*
|
*
|
||||||
* raylib [core] example - Custom logging
|
* raylib [core] example - Custom logging
|
||||||
*
|
*
|
||||||
* Welcome to raylib!
|
* This example has been created using raylib 2.1 (www.raylib.com)
|
||||||
*
|
|
||||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
|
||||||
* Note that compiled executable is placed in the same folder as .c file
|
|
||||||
*
|
|
||||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
|
||||||
* raylib official webpage: www.raylib.com
|
|
||||||
*
|
|
||||||
* Enjoy using raylib. :)
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 2.0 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2018 Ramon Santamaria (@raysan5) and Pablo Marcos Oltra (@pamarcos)
|
* Copyright (c) 2018 Ramon Santamaria (@raysan5) and Pablo Marcos Oltra (@pamarcos)
|
||||||
|
@ -24,7 +14,8 @@
|
||||||
#include <stdio.h> // Required for: fopen(), fclose(), fputc(), fwrite(), printf(), fprintf(), funopen()
|
#include <stdio.h> // Required for: fopen(), fclose(), fputc(), fwrite(), printf(), fprintf(), funopen()
|
||||||
#include <time.h> // Required for: time_t, tm, time(), localtime(), strftime()
|
#include <time.h> // Required for: time_t, tm, time(), localtime(), strftime()
|
||||||
|
|
||||||
void logCustom(int msgType, const char *text, va_list args)
|
// Custom logging funtion
|
||||||
|
void LogCustom(int msgType, const char *text, va_list args)
|
||||||
{
|
{
|
||||||
char timeStr[64];
|
char timeStr[64];
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
@ -41,6 +32,7 @@ void logCustom(int msgType, const char *text, va_list args)
|
||||||
case LOG_DEBUG: printf("[DEBUG]: "); break;
|
case LOG_DEBUG: printf("[DEBUG]: "); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
vprintf(text, args);
|
vprintf(text, args);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
@ -54,7 +46,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
// First thing we do is setting our custom logger to ensure everything raylib logs
|
// First thing we do is setting our custom logger to ensure everything raylib logs
|
||||||
// will use our own logger instead of its internal one
|
// will use our own logger instead of its internal one
|
||||||
SetTraceLogCallback(logCustom);
|
SetTraceLogCallback(LogCustom);
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - custom logging");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - custom logging");
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
#ifndef RAYLIB_H
|
#ifndef RAYLIB_H
|
||||||
#define RAYLIB_H
|
#define RAYLIB_H
|
||||||
|
|
||||||
#include <stdarg.h> // Required for va_list
|
#include <stdarg.h> // Required for: va_list - Only used by TraceLogCallback
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED)
|
#if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED)
|
||||||
#define RLAPI __declspec(dllexport) // We are building raylib as a Win32 shared library (.dll)
|
#define RLAPI __declspec(dllexport) // We are building raylib as a Win32 shared library (.dll)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue