Functions | Variables

log_default.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "log.h"
Include dependency graph for log_default.c:

Go to the source code of this file.

Functions

int gs_log_init (const char *ident, int option, int facility, const char *default_event)
int gs_log_write (const char *file, const int line, const char *function, int level, const char *event, const char *format,...)
int gs_log_finalize ()

Variables

static char * _GS_DEFAULT_LOG_EVENT = NULL
static char * _GS_DEFAULT_LOG_IDENT = NULL

Detailed Description

This file contains logging functions for GridSolve.

Definition in file log_default.c.


Function Documentation

int gs_log_finalize (  ) 

Releases any resources allocated by the logging system.

Returns:
0 on success, -1 on failure.

Definition at line 86 of file log_default.c.

Here is the caller graph for this function:

int gs_log_init ( const char *  ident,
int  option,
int  facility,
const char *  default_event 
)

Initializes the logging system.

Parameters:
ident --
option --
facility --
default_event --
Returns:
0 on success, -1 on failure.

Definition at line 36 of file log_default.c.

{
  fprintf(stderr,"Initializing logging %s %s \n", ident, default_event);
  _GS_DEFAULT_LOG_EVENT = strdup(default_event);
  _GS_DEFAULT_LOG_IDENT = strdup(ident);
  fprintf(stderr,"Set logging %s %s \n", _GS_DEFAULT_LOG_IDENT, _GS_DEFAULT_LOG_EVENT);

  atexit((void (*)())gs_log_finalize);
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int gs_log_write ( const char *  file,
const int  line,
const char *  function,
int  level,
const char *  event,
const char *  format,
  ... 
)

Writes a message to the log.

Parameters:
file --
line --
function --
level --
event --
format --
... --
Returns:
0 on success, -1 on failure.

Definition at line 62 of file log_default.c.

{
  va_list argptr;

  if (event == NULL) {
    fprintf(stderr, "Received NULL event, default %s\n", _GS_DEFAULT_LOG_EVENT);
    event = _GS_DEFAULT_LOG_EVENT;
  }
  fprintf(stderr,"%s:%d [%s] %d %s", file,line,function,level,event);
  
  va_start(argptr, format);
  vfprintf(stderr,format, argptr);
  fflush(stderr);

  return 0;
}

Here is the call graph for this function:


Variable Documentation

char* _GS_DEFAULT_LOG_EVENT = NULL [static]

Definition at line 17 of file log_default.c.

char* _GS_DEFAULT_LOG_IDENT = NULL [static]

Definition at line 18 of file log_default.c.