[wip] logging system
This commit is contained in:
		
							parent
							
								
									caa454f1ca
								
							
						
					
					
						commit
						a1c69fc5f9
					
				
							
								
								
									
										2
									
								
								milepost
								
								
								
								
							
							
								
								
								
								
								
								
							
						
						
									
										2
									
								
								milepost
								
								
								
								
							|  | @ -1 +1 @@ | |||
| Subproject commit 0d6fb197fb5a4ec52dd65d4bd8fd52b7acf0e95e | ||||
| Subproject commit 86a16d3775727fe2b9dfd51fbd62f3f63b087f2e | ||||
|  | @ -39,14 +39,13 @@ mem_arena arena; | |||
| 
 | ||||
| void OnInit(void) | ||||
| { | ||||
| 	mem_arena_init(&arena); | ||||
| //	mem_arena_init(&arena);
 | ||||
| 	font = g_font_create_default(); | ||||
| } | ||||
| 
 | ||||
| void OnFrameResize(u32 width, u32 height) | ||||
| { | ||||
| 	ASSERT(width == 0, "assert if width different from 0"); | ||||
| 	log_print("frame resize %u, %u\n", width, height); | ||||
| //	LOG_INFO("frame resize %u, %u\n", width, height);
 | ||||
| 
 | ||||
| 	frameSize.x = width; | ||||
| 	frameSize.y = height; | ||||
|  | @ -88,7 +87,7 @@ void OnKeyUp(int key) | |||
| 
 | ||||
| void OnFrameRefresh(void) | ||||
| { | ||||
| 	char* tmp = mem_arena_alloc(&arena, 512); | ||||
| //	char* tmp = mem_arena_alloc(&arena, 512);
 | ||||
| 
 | ||||
| 	f32 aspect = frameSize.x/frameSize.y; | ||||
| 
 | ||||
|  | @ -162,5 +161,5 @@ void OnFrameRefresh(void) | |||
| 
 | ||||
|     g_matrix_pop(); | ||||
| 
 | ||||
|     mem_arena_clear(&arena); | ||||
| //    mem_arena_clear(&arena);
 | ||||
| } | ||||
|  |  | |||
|  | @ -8,5 +8,4 @@ | |||
| 
 | ||||
| #include"platform/orca_memory.c" | ||||
| #include"util/memory.c" | ||||
| 
 | ||||
| #include"orca_log.c" | ||||
| #include"util/debug_log.c" | ||||
|  |  | |||
|  | @ -11,7 +11,7 @@ | |||
| #include"util/typedefs.h" | ||||
| #include"util/lists.h" | ||||
| #include"util/memory.h" | ||||
| #include"util/debug_log.h" | ||||
| 
 | ||||
| #include"orca_log.h" | ||||
| 
 | ||||
| #endif //__ORCA_H_
 | ||||
|  |  | |||
|  | @ -1,37 +0,0 @@ | |||
| /************************************************************//**
 | ||||
| * | ||||
| *	@file: orca_log.c | ||||
| *	@author: Martin Fouilleul | ||||
| *	@date: 17/04/2023 | ||||
| * | ||||
| *****************************************************************/ | ||||
| #include"orca_log.h" | ||||
| #include"platform_varg.h" | ||||
| 
 | ||||
| #define STB_SPRINTF_IMPLEMENTATION | ||||
| #include"ext/stb_sprintf.h" | ||||
| 
 | ||||
| extern void orca_log(size_t len, const char* ptr); | ||||
| 
 | ||||
| //TODO: later, move this to orca_strings in milepost
 | ||||
| size_t strlen(const char *s) | ||||
| { | ||||
| 	size_t len = 0; | ||||
| 	while(s[len] != '\0') | ||||
| 	{ | ||||
| 		len++; | ||||
| 	} | ||||
| 	return(len); | ||||
| } | ||||
| 
 | ||||
| void log_print(const char* fmt, ...) | ||||
| { | ||||
| 	char buf[4096]; | ||||
| 
 | ||||
| 	va_list ap; | ||||
| 	va_start(ap, fmt); | ||||
| 	stbsp_vsnprintf(buf, 4096, fmt, ap); | ||||
| 	va_end(ap); | ||||
| 
 | ||||
| 	orca_log(strlen(buf), buf); | ||||
| } | ||||
|  | @ -1,15 +0,0 @@ | |||
| /************************************************************//**
 | ||||
| * | ||||
| *	@file: orca_log.h | ||||
| *	@author: Martin Fouilleul | ||||
| *	@date: 17/04/2023 | ||||
| * | ||||
| *****************************************************************/ | ||||
| #ifndef __ORCA_LOG_H_ | ||||
| #define __ORCA_LOG_H_ | ||||
| 
 | ||||
| #include"typedefs.h" | ||||
| 
 | ||||
| void log_print(const char* s, ...); | ||||
| 
 | ||||
| #endif //__ORCA_LOG_H_
 | ||||
|  | @ -1,4 +1,5 @@ | |||
| orca_log v(ip) | ||||
| orca_log_entry v(iipipi) | ||||
| orca_log_append v(ip) | ||||
| cosf f(f) | ||||
| sinf f(f) | ||||
| floorf f(f) | ||||
|  |  | |||
							
								
								
									
										26
									
								
								src/main.c
								
								
								
								
							
							
						
						
									
										26
									
								
								src/main.c
								
								
								
								
							|  | @ -19,11 +19,29 @@ | |||
| 
 | ||||
| #define LOG_SUBSYSTEM "Orca" | ||||
| 
 | ||||
| 
 | ||||
| /*
 | ||||
| void orca_log(int len, const char* ptr) | ||||
| { | ||||
| 	LOG_MESSAGE("%.*s", len, ptr); | ||||
| 	LOG_INFO("%.*s", len, ptr); | ||||
| } | ||||
| */ | ||||
| 
 | ||||
| void orca_log_entry(log_level level, | ||||
|                     int fileLen, | ||||
|                     char* file, | ||||
|                     int functionLen, | ||||
|                     char* function, | ||||
|                     int line) | ||||
| { | ||||
| 	log_generic(level, file, function, line, ""); | ||||
| } | ||||
| 
 | ||||
| void orca_log_append(int msgLen, char* msg) | ||||
| { | ||||
| 	printf("%s", msg); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| void mg_matrix_push_flat(float a11, float a12, float a13, | ||||
|                          float a21, float a22, float a23) | ||||
|  | @ -222,7 +240,7 @@ void* orca_runloop(void* user) | |||
| 	} | ||||
| 	//NOTE: align heap base on 16Bytes
 | ||||
| 	heapBase = AlignUpOnPow2(heapBase, 16); | ||||
| 	LOG_MESSAGE("mem_size = %u,  __heap_base = %u\n", m3_GetMemorySize(app->runtime.m3Runtime), heapBase); | ||||
| 	LOG_INFO("mem_size = %u,  __heap_base = %u\n", m3_GetMemorySize(app->runtime.m3Runtime), heapBase); | ||||
| 
 | ||||
| 	//NOTE: Find and type check event handlers.
 | ||||
| 
 | ||||
|  | @ -402,7 +420,7 @@ void* orca_runloop(void* user) | |||
| 
 | ||||
| int main(int argc, char** argv) | ||||
| { | ||||
| 	LogLevel(LOG_LEVEL_DEBUG); | ||||
| 	log_set_level(LOG_LEVEL_INFO); | ||||
| 
 | ||||
| 	mp_init(); | ||||
| 	mp_clock_init(); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue