taskrambler  0.1.8
Web server and task management solution.
i_logger.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "logger/logger.h"
#include "logger/interface/logger.h"
#include "utils/memory.h"
+ Include dependency graph for i_logger.c:

Go to the source code of this file.

Functions

void loggerLog (void *_object, logger_level level, const char *const fmt,...)
 

Variables

const struct interface i_Logger
 

Detailed Description

Author
Georg Hopp

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file i_logger.c.

Function Documentation

void loggerLog ( void *  _object,
logger_level  level,
const char *const  fmt,
  ... 
)

Definition at line 38 of file i_logger.c.

References CALL, MEM_FREE, and memMalloc().

Referenced by main(), serverCtor(), serverHandleAccept(), serverPoll(), serverRead(), serverRun(), serverWrite(), socketAccept(), socketConnect(), socketCtor(), socketListen(), streamRead(), and streamWrite().

38  {
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 }
#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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const struct interface i_Logger
Initial value:
= {
"logger",
1
}

Definition at line 32 of file i_logger.c.