mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	Add log.c with info() and warn()
This commit is contained in:
		
							parent
							
								
									5ea1527558
								
							
						
					
					
						commit
						2a17df0f8b
					
				
					 11 changed files with 68 additions and 17 deletions
				
			
		
							
								
								
									
										32
									
								
								src/common/log.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/common/log.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,32 @@
 | 
			
		|||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#define LABWC_COLOR_YELLOW "\033[0;33m"
 | 
			
		||||
#define LABWC_COLOR_RED "\033[0;31m"
 | 
			
		||||
#define LABWC_COLOR_RESET "\033[0m"
 | 
			
		||||
 | 
			
		||||
void info(const char *msg, ...)
 | 
			
		||||
{
 | 
			
		||||
	va_list params;
 | 
			
		||||
	fprintf(stderr, LABWC_COLOR_YELLOW);
 | 
			
		||||
	fprintf(stderr, "[labwc] info: ");
 | 
			
		||||
	va_start(params, msg);
 | 
			
		||||
	vfprintf(stderr, msg, params);
 | 
			
		||||
	va_end(params);
 | 
			
		||||
	fprintf(stderr, LABWC_COLOR_RESET);
 | 
			
		||||
	fprintf(stderr, "\n");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void warn(const char *err, ...)
 | 
			
		||||
{
 | 
			
		||||
	va_list params;
 | 
			
		||||
	fprintf(stderr, LABWC_COLOR_RED);
 | 
			
		||||
	fprintf(stderr, "[labwc] warning: ");
 | 
			
		||||
	va_start(params, err);
 | 
			
		||||
	vfprintf(stderr, err, params);
 | 
			
		||||
	va_end(params);
 | 
			
		||||
	fprintf(stderr, LABWC_COLOR_RESET);
 | 
			
		||||
	fprintf(stderr, "\n");
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue