taskrambler  0.1.9
Web server and task management solution.
i_logger.c
Go to the documentation of this file.
1 /**
2  * \file
3  *
4  * \author Georg Hopp
5  *
6  * \copyright
7  * Copyright © 2012 Georg Hopp
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <stdarg.h>
26 
27 #include "logger/logger.h"
29 
30 #include "utils/memory.h"
31 
32 const struct interface i_Logger = {
33  "logger",
34  1
35 };
36 
37 void
38 loggerLog(void * _object, logger_level level, const char * const fmt, ...) {
39  Logger object = _object;
40 
41  if (level >= object->min_level) {
42  char * msg = NULL;
43  size_t msg_size = 0;
44  va_list params;
45 
46  va_start(params, fmt);
47  msg_size = vsnprintf(NULL, msg_size, fmt, params);
48  va_end(params);
49 
50  msg = memMalloc(msg_size + 1);
51 
52  va_start(params, fmt);
53  vsnprintf(msg, msg_size + 1, fmt, params);
54  va_end(params);
55 
56 // // ----- DEBUG ------
57 // do {
58 // struct i_Logger * iface;
59 //
60 // do {
61 // class_ptr class = GET_CLASS(_object);
62 // iface = (struct i_Logger *)IFACE_GET(class, &i_Logger);
63 // while ((NULL == iface || NULL == iface->log) && HAS_PARENT(class)) {
64 // class = class->parent;
65 // iface = (struct i_Logger *)IFACE_GET(class, &i_Logger);
66 // }
67 // assert(NULL != iface->log);
68 // } while(0);
69 //
70 // iface->log(_object, level, msg);
71 // } while(0);
72 // // ----- DEBUG ------
73  CALL(_object, Logger, log, level, msg);
74 
75  MEM_FREE(msg);
76  }
77 }
78 
79 // vim: set ts=4 sw=4:
#define MEM_FREE(seg)
Definition: memory.h:28
#define CALL(object, _iface, method,...)
Definition: class/class.h:106
void * memMalloc(size_t)
Definition: memory.c:783
logger_level
Definition: logger/logger.h:30
void loggerLog(void *_object, logger_level level, const char *const fmt,...)
Definition: i_logger.c:38