SASC
DVBSoftCAM

cLogging Class Reference

#include <log.h>

List of all members.

Static Public Member Functions

static bool AddModule (int m, const struct LogModule *dm)
static void SetLogPrint (void(*lp)(const struct LogHeader *lh, const char *txt))
static void Printf (int c, const char *format,...) __attribute__((format(printf
static void static void Puts (int c, const char *txt)
static void PutLB (int c, cLineBuff *lb)
static void Dump (int c, const void *data, int n, const char *format,...) __attribute__((format(printf
static void static void LineDump (int c, const void *data, int n, const char *format,...) __attribute__((format(printf
static void static void static bool Enabled (int c)
static void SetModuleOptions (int c)
static int GetModuleOptions (int c)
static void SetModuleOption (int c, bool on)
static void SetModuleDefault (int c)
static const char * GetModuleName (int c)
static const char * GetOptionName (int c)
static void ParseConfig (const char *txt)
static bool GetConfig (cLineBuff *lb)
static void ReopenLogfile (void)
static int GetClassByName (const char *name)
static bool AddModule (int m, const struct LogModule *dm)
static void SetLogPrint (void(*lp)(const struct LogHeader *lh, const char *txt))
static void Printf (int c, const char *format,...) __attribute__((format(printf
static void static void Puts (int c, const char *txt)
static void PutLB (int c, cLineBuff *lb)
static void Dump (int c, const void *data, int n, const char *format,...) __attribute__((format(printf
static void static void LineDump (int c, const void *data, int n, const char *format,...) __attribute__((format(printf
static void static void static bool Enabled (int c)
static void SetModuleOptions (int c)
static int GetModuleOptions (int c)
static void SetModuleOption (int c, bool on)
static void SetModuleDefault (int c)
static const char * GetModuleName (int c)
static const char * GetOptionName (int c)
static void ParseConfig (const char *txt)
static bool GetConfig (cLineBuff *lb)
static void ReopenLogfile (void)
static int GetClassByName (const char *name)

Detailed Description

Definition at line 91 of file log.h.


Member Function Documentation

bool cLogging::AddModule ( int  m,
const struct LogModule *  dm 
) [static]

Definition at line 64 of file log.c.

References config, L_GEN_DEBUG, LCLASS, LMOD_CFG_VALID, LMOD_SUP, LogModule::Name, Printf(), and SetModuleDefault().

{
  if(m<LMOD_SUP) {
    if(mods[m]) Printf(L_GEN_DEBUG,"duplicate logging module id %d (%s & %s)",m,mods[m]->Name,lm->Name);
    mods[m]=lm;
    if(config[m]&LMOD_CFG_VALID) UpgradeOptions(m);
    else SetModuleDefault(LCLASS(m,0));
//printf("module %-16s added. mod=%x supp=%08x def=%08x cfg=%08x\n",lm->Name,m,lm->OptSupported,lm->OptDefault,config[m]);
    }
  else Printf(L_GEN_DEBUG,"failed to add logging module %d (%s)",m,lm->Name);
  return true;
}
static bool cLogging::AddModule ( int  m,
const struct LogModule *  dm 
) [static]
void cLogging::Dump ( int  c,
const void *  data,
int  n,
const char *  format,
  ... 
) [static]

Definition at line 245 of file log.c.

References Enabled().

{
  if(Enabled(c)) {
    struct LogHeader lh;
    if(GetHeader(c,&lh)) {
      char buff[1024];
      va_list ap;
      va_start(ap,format);
      vsnprintf(buff,sizeof(buff),format,ap);
      va_end(ap);
      LogLine(&lh,buff);
      const unsigned char *d=(const unsigned char *)data;
      for(int i=0; i<n;) {
        int q=sprintf(buff,"%04x:",i);
        for(int l=0 ; l<16 && i<n ; l++) q+=sprintf(&buff[q]," %02x",d[i++]);
        LogLine(&lh,buff);
        }
      }
    }
}
static void cLogging::Dump ( int  c,
const void *  data,
int  n,
const char *  format,
  ... 
) [static]
bool cLogging::Enabled ( int  c) [static]

Definition at line 205 of file log.c.

References config, LMOD, LMOD_CFG_VALID, LMOD_ENABLE, LMOD_SUP, and LOPT.

Referenced by Dump(), LineDump(), Printf(), and Puts().

{
  int m=LMOD(c);
  int o=LOPT(c)|LMOD_CFG_VALID|LMOD_ENABLE;
  return m<LMOD_SUP && (config[m] & o)==o;
}
static void static void static bool cLogging::Enabled ( int  c) [static]
int cLogging::GetClassByName ( const char *  name) [static]

Definition at line 389 of file log.c.

References LCLASS, LMOD_SUP, LOPT_NUM, LogModule::Name, LogModule::OptName, and LogModule::OptSupported.

Referenced by cScPlugin::SVDRPCommand().

{
  const char *s=index(name,'.');
  if(s) {
    unsigned int l=s-name;
    for(int m=1; m<LMOD_SUP; m++) {
      const struct LogModule *lm=mods[m];
      if(lm && strlen(lm->Name)==l && !strncasecmp(name,lm->Name,l)) {
        s++;
        if(!strcasecmp(s,"enable"))
           return LCLASS(m,1);
        for(int o=1; o<LOPT_NUM; o++)
          if((lm->OptSupported&(1<<o)) && lm->OptName[o-1] && !strcasecmp(s,lm->OptName[o-1]))
            return LCLASS(m,1<<o);
        break;
        }
      }
    }
  return -1;  
}
static int cLogging::GetClassByName ( const char *  name) [static]
static bool cLogging::GetConfig ( cLineBuff *  lb) [static]
bool cLogging::GetConfig ( cLineBuff *  lb) [static]

Definition at line 355 of file log.c.

References cmask, config, cLineBuff::Flush(), LMOD_CFG_VALID, LMOD_SUP, and cLineBuff::Printf().

Referenced by cScSetup::Store().

{
  lb->Flush();
  bool cont=false;
  for(int m=1; m<LMOD_SUP; m++)
    if(config[m]&LMOD_CFG_VALID) {
      lb->Printf("%s%d:%x:%x",cont?",":"",m,config[m]&~LMOD_CFG_VALID,cmask[m]);
      cont=true;
      }
  return cont;
}
const char * cLogging::GetModuleName ( int  c) [static]

Definition at line 335 of file log.c.

References LogModule::Name.

Referenced by cMenuLogMod::cMenuLogMod(), cMenuLogSys::cMenuLogSys(), and cScPlugin::SVDRPCommand().

{
  const struct LogModule *lm=GetModule(c);
  return lm ? lm->Name : 0;
}
static const char* cLogging::GetModuleName ( int  c) [static]
int cLogging::GetModuleOptions ( int  c) [static]

Definition at line 305 of file log.c.

References config, LMOD, and LOPT.

Referenced by cMenuLogMod::cMenuLogMod(), and cScPlugin::SVDRPCommand().

{
  const struct LogModule *lm=GetModule(c);
  return lm ? LOPT(config[LMOD(c)]) : -1;
}
static int cLogging::GetModuleOptions ( int  c) [static]
static const char* cLogging::GetOptionName ( int  c) [static]
const char * cLogging::GetOptionName ( int  c) [static]

Definition at line 341 of file log.c.

References i, LMOD_ENABLE, LOPT, LogModule::OptName, and LogModule::OptSupported.

Referenced by cMenuLogMod::cMenuLogMod(), and cScPlugin::SVDRPCommand().

{
  const struct LogModule *lm=GetModule(c);
  if(lm) {
    int o=LOPT(c)&~LMOD_ENABLE;
    if(lm->OptSupported & o) {
      int i;
      for(i=0; i<LOPT_NUM; i++,o>>=1) if(o&1) break;
      return (i>=1 && i<LOPT_NUM && lm->OptName[i-1]) ? lm->OptName[i-1] : 0;
      }
    }
  return 0;
}
void cLogging::LineDump ( int  c,
const void *  data,
int  n,
const char *  format,
  ... 
) [static]

Definition at line 266 of file log.c.

References Enabled().

{
  if(Enabled(c)) {
    struct LogHeader lh;
    if(GetHeader(c,&lh)) {
      char buff[4096];
      va_list ap;
      va_start(ap,format);
      unsigned int q=vsnprintf(buff,sizeof(buff),format,ap);
      va_end(ap);
      const unsigned char *d=(const unsigned char *)data;
      for(int i=0; i<n; i++) {
        if(q>=sizeof(buff)-8) {
          q+=snprintf(&buff[q],sizeof(buff)-q,"....");
          break;
          }
        q+=snprintf(&buff[q],sizeof(buff)-q," %02x",d[i]);
        }
      LogLine(&lh,buff);
      }
    }
}
static void static void cLogging::LineDump ( int  c,
const void *  data,
int  n,
const char *  format,
  ... 
) [static]
static void cLogging::ParseConfig ( const char *  txt) [static]
void cLogging::ParseConfig ( const char *  txt) [static]

Definition at line 367 of file log.c.

References cmask, config, LMOD_CFG_VALID, LMOD_SUP, and LOPT_MASK.

Referenced by cScPlugin::SetupParse().

{
  int n=0, l, m, o, d;
  while(sscanf(&txt[n],"%d:%x:%x%n",&m,&o,&d,&l)==3) {
    if(m>=1 && m<LMOD_SUP) {
      config[m]=(o&LOPT_MASK)|LMOD_CFG_VALID;
      cmask[m] =(d&LOPT_MASK);
      UpgradeOptions(m);
      }
    n+=l;
    if(txt[n]!=',') break;
    n++;
    }
}
static void cLogging::Printf ( int  c,
const char *  format,
  ... 
) [static]
void cLogging::Printf ( int  c,
const char *  format,
  ... 
) [static]

Definition at line 212 of file log.c.

References Enabled().

Referenced by AddModule().

{
  if(Enabled(c)) {
    struct LogHeader lh;
    if(GetHeader(c,&lh)) {
      char buff[1024];
      va_list ap;
      va_start(ap,format);
      vsnprintf(buff,sizeof(buff),format,ap);
      va_end(ap);
      LogLine(&lh,buff);
      }
    }
}
void cLogging::PutLB ( int  c,
cLineBuff *  lb 
) [static]

Definition at line 237 of file log.c.

References cLineBuff::Flush(), cLineBuff::Length(), cLineBuff::Line(), and Puts().

Referenced by cLogLineBuff::Flush().

{
  if(lb->Length()>0) {
    Puts(c,lb->Line());
    lb->Flush();
    }
}
static void cLogging::PutLB ( int  c,
cLineBuff *  lb 
) [static]
void cLogging::Puts ( int  c,
const char *  txt 
) [static]

Definition at line 227 of file log.c.

References Enabled().

Referenced by PutLB().

{
  if(txt && Enabled(c)) {
    struct LogHeader lh;
    if(GetHeader(c,&lh)) {
      LogLine(&lh,txt);
      }
    }
}
static void static void cLogging::Puts ( int  c,
const char *  txt 
) [static]
void cLogging::ReopenLogfile ( void  ) [static]

Definition at line 382 of file log.c.

References cMutex::Lock(), logfileReopen, and cMutex::Unlock().

static void cLogging::ReopenLogfile ( void  ) [static]
void cLogging::SetLogPrint ( void(*)(const struct LogHeader *lh, const char *txt)  lp) [static]

Definition at line 77 of file log.c.

Referenced by SetCAMPrint().

{
  LogPrint=lp;
}
static void cLogging::SetLogPrint ( void(*)(const struct LogHeader *lh, const char *txt)  lp) [static]
static void cLogging::SetModuleDefault ( int  c) [static]
void cLogging::SetModuleDefault ( int  c) [static]

Definition at line 289 of file log.c.

References cmask, config, LMOD, LMOD_CFG_VALID, LOPT_MASK, LogModule::OptDefault, and LogModule::OptSupported.

Referenced by AddModule(), cMenuLogSys::ProcessKey(), and cMenuLogMod::ProcessKey().

{
  const struct LogModule *lm=GetModule(c);
  if(lm) {
    int m=LMOD(c);
    config[m]=(lm->OptDefault&LOPT_MASK)|LMOD_CFG_VALID;
    cmask[m] = lm->OptSupported&LOPT_MASK;
    }
}
void cLogging::SetModuleOption ( int  c,
bool  on 
) [static]

Definition at line 311 of file log.c.

References config, LMOD, LMOD_CFG_VALID, LOPT, LOPT_MASK, and LogModule::OptSupported.

Referenced by main(), cMenuLogSys::ProcessKey(), cMenuLogMod::ProcessKey(), and cScPlugin::SVDRPCommand().

{
  const struct LogModule *lm=GetModule(c);
  if(lm) {
    int m=LMOD(c);
    int o=LOPT(c)&(lm->OptSupported&LOPT_MASK);
    if(o) {
      if(on) config[m]|=o; else config[m]&=(~o);
      config[m]|=LMOD_CFG_VALID;
      }
    }
}
static void cLogging::SetModuleOption ( int  c,
bool  on 
) [static]
void cLogging::SetModuleOptions ( int  c) [static]

Definition at line 299 of file log.c.

References config, LMOD, LMOD_CFG_VALID, LOPT, LOPT_MASK, and LogModule::OptSupported.

Referenced by LogAll(), and LogNone().

{
  const struct LogModule *lm=GetModule(c);
  if(lm) config[LMOD(c)]=(LOPT(c)&(lm->OptSupported&LOPT_MASK))|LMOD_CFG_VALID;
}
static void cLogging::SetModuleOptions ( int  c) [static]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines