libtrbase  1.0.2
Web server and task management solution.
i_logger.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "trbase.h"
+ Include dependency graph for i_logger.c:

Go to the source code of this file.

Functions

 TR_CREATE_INTERFACE (TR_Logger, 1)
 
void TR_loggerLog (void *_object, TR_logger_level level, const char *const fmt,...)
 

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

TR_CREATE_INTERFACE ( TR_Logger  ,
 
)
void TR_loggerLog ( void *  _object,
TR_logger_level  level,
const char *const  fmt,
  ... 
)

Definition at line 32 of file i_logger.c.

References TR_CALL, TR_malloc(), and TR_MEM_FREE.

36  {
37  TR_Logger object = _object;
38 
39  if (level >= object->min_level) {
40  char * msg = NULL;
41  size_t msg_size = 0;
42  va_list params;
43 
44  va_start(params, fmt);
45  msg_size = vsnprintf(NULL, msg_size, fmt, params);
46  va_end(params);
47 
48  msg = TR_malloc(msg_size + 1);
49 
50  va_start(params, fmt);
51  vsnprintf(msg, msg_size + 1, fmt, params);
52  va_end(params);
53 
54  TR_CALL(_object, TR_Logger, log, level, msg);
55 
56  TR_MEM_FREE(msg);
57  }
58 }
#define TR_CALL(object, _iface, method,...)
Definition: class.h:256
void * TR_malloc(size_t)
Definition: memory.c:178
#define TR_MEM_FREE(seg)
Definition: memory.h:26

+ Here is the call graph for this function: