feat(lander): fully switch to lnm logger
							parent
							
								
									dde83584a7
								
							
						
					
					
						commit
						8e0477c34b
					
				|  | @ -1,12 +1,13 @@ | |||
| #include <stdio.h> | ||||
| #include <string.h> | ||||
| 
 | ||||
| #include "lnm/http/consts.h" | ||||
| #include "lnm/http/loop.h" | ||||
| #include "lnm/loop.h" | ||||
| #include "lnm/log.h" | ||||
| #include "lsm/store.h" | ||||
| 
 | ||||
| #include "lander.h" | ||||
| #include "log.h" | ||||
| 
 | ||||
| static const char index_page[] = | ||||
|     "<!DOCTYPE html>\n" | ||||
|  | @ -39,7 +40,7 @@ lnm_http_step_err lander_get_redirect(lnm_http_conn *conn) { | |||
|   // This shouldn't be able to happen
 | ||||
|   if (lsm_entry_attr_get(&url_attr_val, c_ctx->entry, lander_attr_type_url) != | ||||
|       lsm_error_ok) { | ||||
|     error("Entry of type redirect detected without URL attribute"); | ||||
|     lnm_lerror("lander", "%s", "Entry of type redirect detected without URL attribute"); | ||||
| 
 | ||||
|     ctx->res.status = lnm_http_status_internal_server_error; | ||||
|     lsm_entry_close(c_ctx->entry); | ||||
|  |  | |||
|  | @ -1,8 +1,9 @@ | |||
| #include <string.h> | ||||
| 
 | ||||
| #include "lnm/loop.h" | ||||
| #include "lsm/store.h" | ||||
| 
 | ||||
| #include "lander.h" | ||||
| #include "log.h" | ||||
| 
 | ||||
| static void randomize_key(char *key, int len) { | ||||
|   size_t charset_len = strlen(lander_key_charset); | ||||
|  |  | |||
							
								
								
									
										31
									
								
								src/log.c
								
								
								
								
							
							
						
						
									
										31
									
								
								src/log.c
								
								
								
								
							|  | @ -1,31 +0,0 @@ | |||
| #include <time.h> | ||||
| 
 | ||||
| #include "log.h" | ||||
| 
 | ||||
| const char *log_level_names[] = {"DEBUG", "INFO ", "WARN ", "ERROR", | ||||
|                                  "CRITICAL"}; | ||||
| 
 | ||||
| log_level _log_level = log_level_debug; | ||||
| 
 | ||||
| void _lander_log(log_level level, FILE *f, const char *fmt, ...) { | ||||
|   if (level < _log_level) { | ||||
|     return; | ||||
|   } | ||||
| 
 | ||||
|   // Log to stdout by default
 | ||||
|   f = (f == NULL) ? stdout : f; | ||||
| 
 | ||||
|   char date_str[32]; | ||||
| 
 | ||||
|   time_t now = time(NULL); | ||||
|   strftime(date_str, sizeof(date_str) - 1, "%Y-%m-%d %H:%M:%S", | ||||
|            localtime(&now)); | ||||
|   fprintf(f, "[%s][%s] ", date_str, log_level_names[level]); | ||||
| 
 | ||||
|   va_list ap; | ||||
|   va_start(ap, fmt); | ||||
|   vfprintf(f, fmt, ap); | ||||
|   va_end(ap); | ||||
| 
 | ||||
|   fprintf(f, "\n"); | ||||
| } | ||||
		Loading…
	
		Reference in New Issue