LIBSSDP
 All Classes Files Functions Variables Typedefs Macros
Macros | Functions
log.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "log.h"
Include dependency graph for log.c:

Go to the source code of this file.

Macros

#define MESSAGE_MAX_SIZE   20480
 

Functions

static int chr_count (char *haystack, char needle)
 
static int fsize (const char *file)
 
void print_debug (FILE *std, const char *color, const char *file, int line, char *va_format,...)
 
void log_start_args (int argc, char **argv)
 

Detailed Description

The logging system.

Definition in file log.c.

Macro Definition Documentation

#define MESSAGE_MAX_SIZE   20480

The printed message's buffer size

Definition at line 18 of file log.c.

Function Documentation

static int chr_count ( char *  haystack,
char  needle 
)
static

Counts the number of times needle occurs in haystack

Parameters
haystackThe string to search in
needleThe character to search for
Returns
int The number of occurrences

Definition at line 29 of file log.c.

static int fsize ( const char *  file)
static

Retrieves the size of a file

Parameters
fileThe file to stat
Returns
The size of the file in Bytes

Definition at line 49 of file log.c.

void log_start_args ( int  argc,
char **  argv 
)

Logs the command line arguments the process was started with.

Parameters
argcThe argc passed to the program/lib.
argvThe argv passed to the program/lib.

Definition at line 219 of file log.c.

void print_debug ( FILE *  std,
const char *  color,
const char *  file,
int  line,
char *  va_format,
  ... 
)

Prints a debug message, mimicking printf-like function, supports only d, s and c

Parameters
stdStandard output to use. color Color to print the message in.
fileThe file the debug message generated in.
lineThe line number in the file the debug message generated at.
messageThe debug message to be displayed.
...Variable number of optional arguments that match with the va_format.

Definition at line 60 of file log.c.