SASC-NG
DVBSoftCAM

log.cpp File Reference

#include <stdio.h>
#include "log.h"

Go to the source code of this file.

Functions

int tmprintf (const char *plugin, const char *fmt,...)
static void LogPrintSasc (const struct LogHeader *lh, const char *txt)
void SetCAMPrint (const char *_plugin_name, unsigned int plugin_id, unsigned int _print_level, unsigned int *_log_level)

Variables

static const char * plugin_name
static unsigned * log_level
static unsigned print_level
static unsigned id

Function Documentation

static void LogPrintSasc ( const struct LogHeader *  lh,
const char *  txt 
) [static]

Definition at line 7 of file log.cpp.

References log_level, plugin_name, print_level, LogHeader::tag, and tmprintf().

Referenced by SetCAMPrint().

                                                                      {
  char tag[80];
  if(print_level <= ((*log_level >> id) & 3)) {
    sprintf(tag, "%s(%s)", plugin_name, lh->tag);
    tmprintf(tag, "%s\n", txt);
  }
}
void SetCAMPrint ( const char *  _plugin_name,
unsigned int  plugin_id,
unsigned int  _print_level,
unsigned int *  _log_level 
)

Definition at line 15 of file log.cpp.

References log_level, LogPrintSasc(), plugin_name, print_level, and cLogging::SetLogPrint().

Referenced by init_sc().

                                                                                                                        {
  plugin_name = _plugin_name;
  id = plugin_id;
  log_level = _log_level;
  print_level = _print_level;
  cLogging::SetLogPrint(&LogPrintSasc);
}
int tmprintf ( const char *  plugin,
const char *  fmt,
  ... 
)

Definition at line 79 of file forward.c.

References logcfg, LOGMODE_STDOUT, LOGMODE_SYSLOG, NULL, and tmprintf_mutex.

{
  va_list args;
  struct timeval tv;
  struct tm tm;
  unsigned long usec;
  char stamp[32], logmsg[1024];
  gettimeofday(&tv, NULL);
  localtime_r(&tv.tv_sec, &tm);
  strftime(stamp,sizeof(stamp),"%b %e %T",localtime_r(&tv.tv_sec, &tm));
  usec = tv.tv_usec;
  pthread_mutex_lock(&tmprintf_mutex);
  /*
   ** Display the remainder of the message
   */
  va_start(args,fmt);
  vsnprintf(logmsg,sizeof(logmsg),fmt,args);
  va_end(args); 
  if(logcfg.logmode & LOGMODE_STDOUT)
    fprintf(stdout, "%s.%03lu %s: %s", stamp, usec/1000, plugin, logmsg);
  if(logcfg.logmode & LOGMODE_SYSLOG)
    syslog(LOG_INFO, "%s: %s", plugin, logmsg);
  pthread_mutex_unlock(&tmprintf_mutex);
   return 0;
}

Variable Documentation

unsigned* log_level [static]

Definition at line 5 of file log.cpp.

Referenced by LogPrintSasc(), and SetCAMPrint().

const char* plugin_name [static]

Definition at line 4 of file log.cpp.

Referenced by LogPrintSasc(), and SetCAMPrint().

unsigned print_level

Definition at line 5 of file log.cpp.

Referenced by LogPrintSasc(), and SetCAMPrint().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines