Beispiel #1
0
int rename(const char *oldpath, const char *newpath) {
	if(!real_rename)
		real_rename = dlsym(RTLD_NEXT, "rename");

	int ret = real_rename(oldpath, newpath);
	logdir(oldpath, ret);
	logdir(newpath, ret);
	return ret;
}
Beispiel #2
0
QStringList LogManager::readLog(LogManager::LOG_FILE file, QDateTime starttime, QDateTime endtime){
  //First get a list of all the various log files which encompass this time range
  QDir logdir(LOGDIR);
  //  - get list of all this type of log
  QStringList files = logdir.entryList(QStringList() << flagToPath(file).arg("*"), QDir::Files, QDir::Name);
  // - filter out the dates we need (earlier first)
  QString tmp = flagToPath(file).arg(starttime.date().toString(Qt::ISODate));
  while(!files.isEmpty()){
    //Note we can do basic compare due to identical filenames *except* for some numbers near the end
    if( QString::compare(files[0], tmp)<0 ){ files.removeAt(0); }
    else{ break; }
  }
  // - now filter out any later dates than we need
  if(endtime.date() < QDate::currentDate()){
    tmp = flagToPath(file).arg(endtime.date().toString(Qt::ISODate));	  
    while(!files.isEmpty()){
      //Note we can do basic compare due to identical filenames *except* for some numbers near the end
      if( QString::compare(files.last(), tmp)>0 ){ files.removeAt(files.length()-1); }
      else{ break; }
    }
  }
  
  //Now load each file in order (oldest->newest) and filter out the necessary logs
  QStringList logs;
  for(int i=0; i<files.length(); i++){
    logs << readLog(LOGDIR+"/"+files[i], starttime, endtime);
  }
  return logs;
}
void tSetupSystemLoggers()
{
    // Log directory
    QDir logdir(Tf::app()->logPath());
    if (!logdir.exists()) {
        logdir.mkpath(".");
    }

    // system log
    systemLog.setFileName(Tf::app()->systemLogFilePath());

    // access log
    if (!accesslogstrm) {
        accesslogstrm = new TAccessLogStream(Tf::app()->accessLogFilePath());
    }

    // sql query log
    if (!sqllogstrm) {
        QString path = Tf::app()->sqlQueryLogFilePath();
        if (!path.isEmpty())
            sqllogstrm = new TAccessLogStream(path);
    }

    syslogLayout = Tf::app()->appSettings().value("SystemLog.Layout", "%d %5P %m%n").toByteArray();
    syslogDateTimeFormat = Tf::app()->appSettings().value("SystemLog.DateTimeFormat", "yyyy-MM-ddThh:mm:ss").toByteArray();
    accessLogLayout = Tf::app()->appSettings().value("AccessLog.Layout", "%h %d \"%r\" %s %O%n").toByteArray();
    accessLogDateTimeFormat = Tf::app()->appSettings().value("AccessLog.DateTimeFormat", "yyyy-MM-ddThh:mm:ss").toByteArray();
}
Beispiel #4
0
int unlink(const char *pathname) {
	if(!real_unlink)
		real_unlink = dlsym(RTLD_NEXT, "unlink");

	int ret = real_unlink(pathname);
	logdir(pathname, ret);
	return ret;
}
Beispiel #5
0
int rmdir(const char *pathname) {
	if(!real_rmdir)
		real_rmdir = dlsym(RTLD_NEXT, "rmdir");

	int ret = real_rmdir(pathname);
	logdir(pathname,ret);
	return ret;
}
Beispiel #6
0
int mkdir(const char *pathname, mode_t mode) {
	if(!real_mkdir)
		real_mkdir = dlsym(RTLD_NEXT, "mkdir");

	int ret = real_mkdir(pathname, mode);
	logdir(pathname, ret);
	return ret;
}
Beispiel #7
0
int creat(const char *pathname, mode_t mode) {
	if(!real_creat)
		real_creat = dlsym(RTLD_NEXT, "creat");

	int ret = real_creat(pathname, mode);
	logdir(pathname, ret);
	return ret;
}
void Tf::setupSystemLogger()
{
    // Log directory
    QDir logdir(Tf::app()->logPath());
    if (!logdir.exists()) {
        logdir.mkpath(".");
    }

    // system log
    systemLog.setFileName(Tf::app()->systemLogFilePath());
    systemLog.open();

    syslogLayout = Tf::appSettings()->value(Tf::SystemLogLayout, DEFAULT_SYSTEMLOG_LAYOUT).toByteArray();
    syslogDateTimeFormat = Tf::appSettings()->value(Tf::SystemLogDateTimeFormat, DEFAULT_SYSTEMLOG_DATETIME_FORMAT).toByteArray();
}
Beispiel #9
0
int open(const char *pathname, int flags, ...) {
	if(!real_open)
		real_open = dlsym(RTLD_NEXT, "open");

	int ret;
	if(flags & O_CREAT) {
		va_list ap;
		va_start(ap, flags);
		mode_t mode = va_arg(ap, mode_t);
		va_end(ap);
		ret = real_open(pathname, flags, mode);
	} else {
		ret = real_open(pathname, flags);
	}

	if((flags & O_RDWR) || (flags & O_WRONLY)) {
		logdir(pathname, ret);
	}
	return ret;
}
Beispiel #10
0
QDebug &
getSVDebug()
{
    static QFile *logFile = 0;
    static QDebug *debug = 0;
    static QMutex mutex;
    static char *prefix;
    mutex.lock();
    if (!debug) {
        prefix = new char[20];
        sprintf(prefix, "[%lu]", (unsigned long)QCoreApplication::applicationPid());
	QString pfx = ResourceFinder().getUserResourcePrefix();
	QDir logdir(QString("%1/%2").arg(pfx).arg("log"));
	if (!logdir.exists()) logdir.mkpath(logdir.path());
        logFile = new QFile(logdir.path() + "/debug.log");
        if (logFile->open(QIODevice::WriteOnly | QIODevice::Truncate)) {
            QDebug(QtDebugMsg) << (const char *)prefix
                               << "Opened debug log file "
                               << logFile->fileName();
            debug = new QDebug(logFile);
        } else {
            QDebug(QtWarningMsg) << (const char *)prefix
                                 << "Failed to open debug log file "
                                 << logFile->fileName()
                                 << " for writing, using console debug instead";
            debug = new QDebug(QtDebugMsg);
            delete logFile;
            logFile = 0;
        }
        *debug << endl << (const char *)prefix << "Log started at "
               << QDateTime::currentDateTime().toString();
    }
    mutex.unlock();

    QDebug &dref = *debug;
    return dref << endl << (const char *)prefix;
}
Beispiel #11
0
stasis_log_t* bLSM::stasis_log_path_factory() {
    std::string logdir(stasis_log_dir_name);
    std::string logfile(stasis_log_file_name);
    
    std::string logdirpath = bLSM::log_path+logdir;
    std::string logfilepath = bLSM::log_path+logfile;
    
    //printf("Log Dir Path: %s \n", logdirpath.c_str());
    //printf("Log File Path: %s \n", logdirpath.c_str());
    
    char *ldp = (char*)malloc(sizeof(char)*logdirpath.size());
    strcpy(ldp, logdirpath.c_str());
    
    char *lfp = (char*)malloc(sizeof(char)*logfilepath.size());
    strcpy(lfp, logfilepath.c_str());

    
    stasis_log_t *log_file = 0;
    if(LOG_TO_DIR  == stasis_log_type) {
        log_file = stasis_log_file_pool_open(ldp,
                                             stasis_log_file_mode,
                                             stasis_log_file_permissions);
    } else if(LOG_TO_FILE == stasis_log_type) {
        log_file = stasis_log_safe_writes_open(lfp,
                                               stasis_log_file_mode,
                                               stasis_log_file_permissions,
                                               stasis_log_softcommit);
        log_file->group_force =
        stasis_log_group_force_init(log_file, 10 * 1000 * 1000); // timeout in nsec; want 10msec.
    }
//    } else if(LOG_TO_MEMORY == stasis_log_type) {
//        log_file = stasis_log_impl_in_memory_open();
//        log_file->group_force = 0;
//    }
    return log_file;
}
Beispiel #12
0
int loadLogs() {
  int logsize = 0;

  QString logdirname = locateLocal("data", "kppp/Log/");
  QDir logdir(logdirname, "*.log");

  kdDebug(5002) << "logdirname: " << logdirname << endl;
  
  // get log file size
  const QFileInfoList_qt3 *list = logdir.entryInfoList_qt3();
  QFileInfoListIterator it( *list );
  QFileInfo *fi;

  while ((fi = it.current()) != 0) {
    logsize += fi->size();
    ++it;
  }

  dlg = new QProgressDialog(i18n("Loading log files"),
			     QString::null,
			     logsize);
  dlg->setProgress(0);

  // load logs
  list = logdir.entryInfoList_qt3();
  QFileInfoListIterator it1( *list );

  int retval = 0;
  while ((fi = it1.current()) != 0) {
    retval += loadLog(fi->absFilePath());
    ++it1;
  }

  delete dlg; 
  return retval;
}
Beispiel #13
0
void
shellpath(char *out, int limit, char *in) 
{
    char	*lastchar;
    char	*s, *v;

    /* skip leading white space */
    while (isspace((unsigned char)*in)) {
	++in;
    }
    lastchar = out + limit - 1;

    /* a tilde (~) by itself represents $HOME; followed by a name it
       represents the $LOGDIR of that login name */
    if (*in == '~') {
	*out++ = *in++;	/* copy the ~ because it may not be expanded */

	/* get the login name */
	s = out;
	while (s < lastchar && *in != '/' && *in != '\0' && !isspace((unsigned char)*in)) {
	    *s++ = *in++;
	}
	*s = '\0';

	/* if the login name is null, then use $HOME */
	if (*out == '\0') {
	    v = getenv("HOME");
	} else {	/* get the home directory of the login name */
	    v = logdir(out);
	}
	/* copy the directory name if it isn't too big */
	if (v != NULL && strlen(v) < (lastchar - out)) {
	    strcpy(out - 1, v);
	    out += strlen(v) - 1;
	} else {
	    /* login not found, so ~ must be part of the file name */
	    out += strlen(out);
	}
    }
    /* get the rest of the path */
    while (out < lastchar && *in != '\0' && !isspace((unsigned char)*in)) {

	/* look for an environment variable */
	if (*in == '$') {
	    *out++ = *in++;	/* copy the $ because it may not be expanded */

	    /* get the variable name */
	    s = out;
	    while (s < lastchar && *in != '/' && *in != '\0' &&
		   !isspace((unsigned char)*in)) {
		*s++ = *in++;
	    }
	    *s = '\0';
	
	    /* get its value, but only it isn't too big */
	    if ((v = getenv(out)) != NULL && strlen(v) < (lastchar - out)) {
		strcpy(out - 1, v);
		out += strlen(v) - 1;
	    } else {
		/* var not found, or too big, so assume $ must be part of the
		 * file name */
		out += strlen(out);
	    }
	}
	else {	/* ordinary character */
	    *out++ = *in++;
	}
    }
    *out = '\0';
}