Back to index

nordugrid-arc-nox  1.1.0~rc6
Defines | Functions
logger.cpp File Reference
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <unistd.h>
#include <string.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <arc/Logger.h>
#include "client.h"

Go to the source code of this file.

Defines

#define olog   (std::cerr)
#define odlog(LEVEL)   (std::cerr)

Functions

int logger (const char *url, char const *const *dirs, int num, time_t ex_period=0)
int main (int argc, char *argv[])

Define Documentation

#define odlog (   LEVEL)    (std::cerr)

Definition at line 20 of file logger.cpp.

#define olog   (std::cerr)

Definition at line 19 of file logger.cpp.


Function Documentation

int logger ( const char *  url,
char const *const *  dirs,
int  num,
time_t  ex_period = 0 
)
int main ( int  argc,
char *  argv[] 
)

Definition at line 28 of file logger.cpp.

                                {
  char* url = NULL;

  Arc::LogStream logcerr(std::cerr);
  Arc::Logger::getRootLogger().addDestination(logcerr);
  Arc::Logger::getRootLogger().setThreshold(Arc::WARNING);

  opterr=0;
  time_t ex_period = 0;
  int n;
  const char* basename = strrchr(argv[0],'/');
  if(basename == NULL) basename=argv[0];
  while((n=getopt(argc,argv,":hu:d:E:")) != -1) {
    switch(n) {
      case ':': { olog<<"Missing argument\n"; return 1; };
      case '?': { olog<<"Unrecognized option\n"; return 1; };
      case 'h': {
        std::cout<<"logger [-h] [-d level] [-u url] [-E expiration_period_days] control_dir ..."<<std::endl;
         return 0;
      };
      case 'u': {
        url=optarg;
      }; break;
      case 'd': {
        char* p;
        int i = strtol(optarg,&p,10);
        if(((*p) != 0) || (i<0)) {
          olog<<"Improper debug level '"<<optarg<<"'"<<std::endl;
          exit(1);
        };
//        LogTime::Level(NotifyLevel(FATAL+i));
      }; break;
      case 'E': {
        char* p;
        int i = strtol(optarg,&p,10);
        if(((*p) != 0) || (i<=0)) {
          olog<<"Improper expiration period '"<<optarg<<"'"<<std::endl;
          exit(1);
        };
        ex_period=i; ex_period*=(60*60*24);
      }; break;
      default: { olog<<"Options processing error\n"; return 1; };
    };
  };
  return logger(url,argv+optind,argc-optind,ex_period);
}

Here is the call graph for this function: