Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review logging system #1065

Closed
2 tasks done
raysan5 opened this issue Jan 12, 2020 · 5 comments
Closed
2 tasks done

Review logging system #1065

raysan5 opened this issue Jan 12, 2020 · 5 comments
Labels
enhancement This is an improvement of some feature

Comments

@raysan5
Copy link
Owner

raysan5 commented Jan 12, 2020

Current logging system needs several improvements.

  • TraceLog() messages should be properly categorized and unified, they need to be standardized in some way:
> DEVICE INIT/CLOSE + INFO ---> Window, Graphics, Audio, Network
> DATA LOADING CPU/GPU -------> Image, Texture, Font, Mesh, Shader, Sound, Music
> Internal Processes ---------> Shader compilation, VBO overflow...
  • Current system is designed in a way that messages are ALWAYS stored inside the binary. It would be interesting to review this design... probably using macros.
@raysan5
Copy link
Owner Author

raysan5 commented Jan 15, 2020

To address second point, I've been analyzing all modules issuing printf()/puts() calls and consequently storing its message data in the binary. I'd like to avoid unneeded information on release builds.

module type comment on calls state
par_shapes.h external par_shapes_export() ✔️
par_shapes.h external 2 debug calls + 1 printf() call + 1 puts() ❗️
tinyobj_loader.c external 2 printf() for error messages (stderr) ❗️
miniaudio.h external multiple printf() calls on #define MA_DEBUG_OUTPUT ✔️
utils.c src TraceLog() implementation ✔️
rlgl.h src TraceLog() implementation (standalone) ✔️
textures.c src ExportImageAsCode() ✔️
models.c src ExportMesh() [OBJ export] ✔️
raudio.c src ExportWaveAsCode() ✔️
raudio.c src TraceLog() implementation (standalone) ✔️
physac.h src multiple printf() calls ❗️
rnet.c src multiple printf() calls ❗️

Proposed solution implies replacing all TraceLog() calls by a macro: TRACELOG:

#if defined(SUPPORT_TRACELOG_OUTPUT)
    #define TRACELOG(level, ...) TraceLog(level, __VA_ARGS__)
#else
    #define TRACELOG(level, ...) {}
#endif

@raysan5 raysan5 added the enhancement This is an improvement of some feature label Jan 16, 2020
@raysan5 raysan5 mentioned this issue Jan 28, 2020
3 tasks
@raysan5 raysan5 changed the title [core] Review logging system Review logging system Jan 28, 2020
@a3f
Copy link
Contributor

a3f commented Feb 1, 2020

Proposed solution implies replacing all TraceLog() calls by a macro: TRACELOG:

#if defined(SUPPORT_TRACELOG_OUTPUT)
   #define TRACELOG(level, ...) TraceLog(level, __VA_ARGS__)
#else
   #define TRACELOG(level, ...) {}
#endif

Two Suggestions:

  • The #else clause should be void(0), otherwise you run into problems with statements:
    if (cond) TRACELOG("WARN: foo bar baz\n"); else do_something(); becomes if (cond) {} ; else { }, which is a compile error

  • Being able to set a log level at runtime and compiletime, is often useful. Former for debugging, latter for reducing application size. e.g.

#if TRACE_LOG_LEVEL >= TRACE_DEBUG
#define TraceLogDebug(...) TraceLog(TRACE_DEBUG, __VA_ARGS__)
#else
#define TraceLogDebug(...) (void)0
#endif

static enum loglevel max_level;
void TraceLog(enum loglevel level)
{
    if (level > level_max)
       return;
}

@raysan5
Copy link
Owner Author

raysan5 commented Feb 3, 2020

@a3f thank you very much for the review! I implemented both suggestions in 1f53fc3.

@raysan5
Copy link
Owner Author

raysan5 commented Feb 3, 2020

Replaced TraceLog() function call by TRACELOG macro on commit cde26c7.

@raysan5
Copy link
Owner Author

raysan5 commented Mar 27, 2020

TraceLog messages have been reviewed in multiple commits:
28da252, b9dd459, bc2c625, 0c6c421, 7e2b1b4, 70ed975, c7e9951.

Messages have been categorized in multiple ways:

by libs:       GLFW, GLAD, GL
by platform:   ANDROID, RPI, UWP, WEB
by system:     DISPLAY, INPUT, FILEIO, TIMER, SYSTEM, RLGL, AUDIO
by data type:  
               IMAGE, TEXTURE, FONT
               SHADER, FBO, VAO, VBO
               MODEL, MESH, MATERIAL
               WAVE, SOUND, STREAM

Probably these categories and the messages will be reviewed in the future but here we go!

@raysan5 raysan5 closed this as completed Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an improvement of some feature
Projects
None yet
Development

No branches or pull requests

2 participants