예제 #1
0
Logger::Logger()
{
	openLogFile(MAIN);
	openLogFile(WINDOWMANAGER);
	openLogFile(RESOURCEMANAGER);
	openLogFile(SCENEMANAGER);
}
예제 #2
0
파일: Log.cpp 프로젝트: imane-jym/gp
void Log::LogFileChange()
{
	ChangeLogFile("LogFile");
	ChangeLogFile("CharLogFile");
	ChangeLogFile("ChatLogFile");

    logfile = openLogFile("LogFile", NULL, "a");
    charLogfile = openLogFile("CharLogFile", NULL, "a");
    chatLogfile = openLogFile("ChatLogFile", NULL, "a");
}
예제 #3
0
/*
 *	serviceSighupRequest()
 *
 */
static void serviceSighupRequest(void *pParam)
{
	struct ioc_log_server	*pserver = (struct ioc_log_server *)pParam;
	char			buff[256];
	int			status;

	/*
	 * Read and discard message from pipe.
	 */
	(void) read(sighupPipe[0], buff, sizeof buff);

	/*
	 * Determine new log file name.
	 */
	status = getDirectory();
	if (status<0){
		fprintf(stderr, "iocLogServer: failed to determine new log "
			"file name\n");
		return;
	}

	/*
	 * Try (re)opening the file.
	 */
	status = openLogFile(pserver);
	if(status<0){
		fprintf(stderr,
			"File access problems to `%s' because `%s'\n", 
			ioc_log_file_name,
			strerror(errno));
		/* Revert to old filename */
		strcpy(ioc_log_file_name, pserver->outfile);
		status = openLogFile(pserver);
		if(status<0){
			fprintf(stderr,
				"File access problems to `%s' because `%s'\n",
				ioc_log_file_name,
				strerror(errno));
			return;
		}
		else {
			fprintf(stderr,
				"iocLogServer: re-opened old log file %s\n",
				ioc_log_file_name);
		}
	}
	else {
		fprintf(stderr,
			"iocLogServer: opened new log file %s\n",
			ioc_log_file_name);
	}
}
예제 #4
0
void
openSystemLog (void) {
#if defined(WINDOWS)
  if (windowsEventLog == INVALID_HANDLE_VALUE) {
    windowsEventLog = RegisterEventSource(NULL, PACKAGE_TARNAME);
  }

#elif defined(__MSDOS__)
  if (!logFile) {
    char *path = makeWritablePath(PACKAGE_TARNAME ".log");

    if (path) {
      openLogFile(path);
      free(path);
    }
  }

#elif defined(__ANDROID__)

#elif defined(HAVE_SYSLOG_H)
  if (!syslogOpened) {
    openlog(PACKAGE_TARNAME, LOG_PID, LOG_DAEMON);
    syslogOpened = 1;
  }
#endif /* open system log */
}
예제 #5
0
  //--------------------------------------------------------------------------------
  void LogStream::locked_write(std::string &s) const
  {
    boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time();
    std::string              str = boost::posix_time::to_iso_string(now) + " [" + getSource() + "] " + s;

    try {
      boost::lock_guard<boost::mutex> guard(objMutex);
      if(!outFile.is_open()) {
        openLogFile();
      }

      stringPool.push_back(str);

      if((stringPool.size() > maxBufferSize || doFlush) && outFile.is_open()) {
        while(stringPool.size() > 0) {
          outFile << stringPool.front() << std::endl;
          if(log2consoleFlag) {
            std::cout << stringPool.front() << std::endl;
          }
          stringPool.pop_front();
        }
        outFile << std::flush;
      }
    } catch(std::runtime_error &e) {
      stringPool.push_back(str);
    }
  }
예제 #6
0
파일: common.c 프로젝트: hlide/jpcsp
void writeLog(const char *s, int length) {
	if (commonInfo->inWriteLog) {
		appendToLogBuffer(s, length);
		return;
	}

	commonInfo->inWriteLog++;

	if (!commonInfo->logKeepOpen) {
		openLogFile();
	}

	flushLogBuffer();

	if (ioWrite(commonInfo->logFd, s, length) < 0) {
		// Can't write to the log file right now, probably because the interrupts are disabled.
		// Save the log string for later output.
		appendToLogBuffer(s, length);
	} else {
		flushLogBuffer();
	}

	if (!commonInfo->logKeepOpen) {
		closeLogFile();
	}

	commonInfo->inWriteLog--;
}
예제 #7
0
BOOL CLogFile::WriteLogFile(LPCTSTR log_message)
{
	BOOL result = FALSE;

	_ASSERT(log_message);
	if (log_message) {
		LPSTR write_buf;
		int len = PrepareBuffer(log_message, _tcslen(log_message) + 1, &write_buf);
		if (len <= 0)
			return FALSE;

		EnterCriticalSection(log_cs);
		{
			HANDLE hFile = openLogFile();
			if (hFile != INVALID_HANDLE_VALUE) {
				DWORD bytes;

				SetFilePointer(hFile, 0, NULL, FILE_END);
				_ASSERT(write_buf);
				if (WriteFile(hFile, write_buf, len - 1, &bytes, NULL)) {
					last_write_time = GetTickCount();
					result = TRUE;
				}
				CloseHandle(hFile);
			}
		}
		LeaveCriticalSection(log_cs);

		VirtualFree(write_buf, 0, MEM_RELEASE);
	}
	else 
		return TRUE;

	return result;
}
예제 #8
0
static int replace_log(int ac,const char **avp[],int mac,const char *nav[],PVStr(nab))
{	FILE *lfp;
	int ai,nac;
	const char **av;

	if( DELEGATE_getEnv(P_LOGFILE) == 0 )
		return ac;

	if( (lfp = openLogFile(time(NULL))) == NULL )
		return ac;

	av = *avp;
	nac = 0;
	for( ai = 0; ai < ac; ai++ ){
		if( mac-3 <= nac ){
			break;
		}
		nav[nac++] = av[ai];
	}
	/* LOGFILE parameter from CRON-expire will be ignored with
	 * prefix "-ign" like -ign LOGFILE=path.
	 */

	nav[nac++] = "-log";
	sprintf(nab,"-%d",fileno(lfp));
	nav[nac++] = nab;
	nav[nac] = NULL;
	*avp = nav;
	return nac;
}
예제 #9
0
// CmpErrLog::CmpErrLog() constructs a CmpErrLog object and 
// contains all of the calls that are necessary for logging
// information about the current state of the compiler.
CmpErrLog::CmpErrLog(const char *failureTxt, CollHeap *failedHeap, size_t size)
  : fp(0)
{
  // If memory is allocated, then free it to give some extra memory
  // for logging.
  if (memPtr != NULL)
  {
    free(memPtr);
    memPtr = NULL;
  }

  // Create and lock the log file.
  openLogFile();

  // If the log file was opened successfully, then write the
  // information to the log file.
  if (fp != NULL)
  {
    writeHeader(failureTxt, failedHeap, size);
    writeMemoryStats();
    writeAllHeapInfo(failedHeap);
    writeCQDInfo();
    writeQueryInfo();
    writeStackTrace();
    closeLogFile();
  }
}
예제 #10
0
void allowLog(const char* message)
{
	if( openLogFile() )
	{
		closeLogFile();
	}
}
예제 #11
0
파일: common.c 프로젝트: sum2012/JpcspTrace
void writeLog(const char *s, int length) {
	int forceBuffering = (dobuffering++ % 60) != 0;
	int restLength = commonInfo->maxLogBufferLength - commonInfo->logBufferLength;
	if (restLength < 512)
		forceBuffering = 0;
	if (commonInfo->inWriteLog || forceBuffering) {
		appendToLogBuffer(s, length);
		return;
	}

	commonInfo->inWriteLog++;

	if (!commonInfo->logKeepOpen) {
		openLogFile();
	}

	flushLogBuffer();

	if (sceIoWrite(commonInfo->logFd, s, length) < 0) {
		// Can't write to the log file right now, probably because the interrupts are disabled.
		// Save the log string for later output.
		appendToLogBuffer(s, length);
	} else {
		flushLogBuffer();
	}

	if (!commonInfo->logKeepOpen) {
		closeLogFile();
	}

	commonInfo->inWriteLog--;
}
예제 #12
0
파일: logstream.cpp 프로젝트: respu/kisscpp
//--------------------------------------------------------------------------------
void LogStream::locked_write(std::string &s)
{
  boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time();
  std::string              str = boost::posix_time::to_iso_string(now) + " " + s;

  try {
    boost::lock_guard<boost::mutex> guard(objMutex);
    if(!outFile.is_open()) {
      openLogFile();
    }

    if(!outFile.is_open()) {
      stringPool.push_back(str);
    } else {
      while(stringPool.size() > 0) {
        outFile << stringPool.front() << std::endl;
        if(log2consoleFlag) {
          std::cout << stringPool.front() << std::endl;
        }
        stringPool.pop_front();
      }

      outFile << str << std::endl;
      if(log2consoleFlag) {
        std::cout << str << std::endl;
      }
    }
  } catch(std::runtime_error &e) {
    stringPool.push_back(str);
  }
}
예제 #13
0
// Each token of the specified path is
// searched into the specified dictionary.
LimaStatusCode FullTokenXmlLogger::process(
  AnalysisContent& analysis) const
{
  TimeUtils::updateCurrentTime();
  LinguisticMetaData* metadata=static_cast<LinguisticMetaData*>(analysis.getData("LinguisticMetaData"));
  if (metadata == 0)
  {
    DICTIONARYLOGINIT;
    LERROR << "no LinguisticMetaData ! abort" << LENDL;
    return MISSING_DATA;
  }

  AnalysisGraph* tokenList=static_cast<AnalysisGraph*>(analysis.getData(m_graphId));
  std::ofstream fout;
  if (!openLogFile(fout,metadata->getMetaData("FileName"))) {
    MORPHOLOGINIT;
    LERROR << "Error: cannot open log file" << LENDL;
    return CANNOT_OPEN_FILE_ERROR;
  }

  dump(fout, *tokenList);
  fout.close();
  TimeUtils::logElapsedTime("FullTokenXmlLogger");
  return SUCCESS_ID;
}
KovanTestWindow::KovanTestWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::KovanTestWindow)
{
	QApplication::setStyle(new BiggerScrollbar);

	ui->setupUi(this);

	// Start on the "Start Screen"
	ui->startScreen->setVisible(true);
	ui->mainScreen->setVisible(false);
	ui->debugScreen->setVisible(false);

	ui->debugActiveLabel->setVisible(false);
	ui->selectTestButton->setVisible(false);

	ui->startTestsButton->setVisible(false);
	ui->lookingForUSBLabel->setVisible(true);

#ifdef linux
	showFullScreen();
#endif

    engine = new KovanTestEngine(this);
    engine->loadAllTests();

	// Wire up all start-screen UI buttons
    connect(ui->startTestsButton, SIGNAL(clicked(bool)),
            this, SLOT(startTests()));

	connect(ui->debugMode1, SIGNAL(clicked(bool)),
			this, SLOT(debugMode1Clicked()));
	connect(ui->debugMode2, SIGNAL(clicked(bool)),
			this, SLOT(debugMode2Clicked()));
	connect(ui->debugMode3, SIGNAL(clicked(bool)),
			this, SLOT(debugMode3Clicked()));

	connect(ui->runSelectedTestsButton, SIGNAL(clicked()),
			this, SLOT(debugRunSelectedItems()));

	connect(ui->testSelectionButton, SIGNAL(clicked()),
			this, SLOT(moveToDebugScreen()));


	// Print out the serial number to the screen
	serialLabelString.sprintf("Serial number: %s",
							  (const char *)(engine->serialNumber().toAscii()));
	ui->serialLabel->setText(serialLabelString);

	// Start the secret debug code at stage 0
	sequencePosition = 0;


	openLogFile();

	ui->startTestsButton->setVisible(true);
	ui->lookingForUSBLabel->setVisible(false);

}
예제 #15
0
void denyLog(const char* message)
{
	if( openLogFile() )
	{
		// writeEncDecLog(LOG_INFO, false, message);

		closeLogFile();
	}
}
예제 #16
0
파일: devsw.c 프로젝트: RodneyBates/M3Devel
void DevSW_SetLogEnable (int logEnableFlag)
{
  if (logEnableFlag && !angelDebugLogFile)
    openLogFile ();
  else if (!logEnableFlag && angelDebugLogFile)
    closeLogFile ();
  
  angelDebugLogEnable = logEnableFlag;
}
예제 #17
0
 std::unique_ptr<std::ofstream> createLogFile(const std::string &file_with_full_path) {
   std::unique_ptr<std::ofstream> out(new std::ofstream);
   std::ofstream &stream(*(out.get()));
   bool success_with_open_file = openLogFile(file_with_full_path, stream);
   if (false == success_with_open_file) {
     out.release();
   }
   return out;
 }
예제 #18
0
void errorLog(const char* message)
{
	if( openLogFile() )
	{
		char logBuf[256] = {'\0', };
		sprintf(logBuf, "SYSLOG: %s", message);
		syslog(LOG_ERR, logBuf);
		closeLogFile();
	}
}
예제 #19
0
파일: Logger.cpp 프로젝트: Junios/Falcor
    void Logger::init()
    {
#if _LOG_ENABLED
        if(sInit == false)
        {
            sLogFile = openLogFile();
            sInit = sLogFile != nullptr;
            assert(sInit);
        }
#endif
    }
예제 #20
0
static void
cmd_log(const char *cmd, const char *args)
{
    char vn[MAX_CMDLEN];
    if (get_token(&args, vn, sizeof(vn))) {
        ScriptError("file name expected");
        return;
    }
    int ret = openLogFile(vn);
    if (ret)
        ScriptError("Cannot open file `%s' for writing", vn);
}
예제 #21
0
// Initialize the haret application.
void
setupHaret()
{
    preparePath();

    // Open log file "haretlog.txt" if "earlyharetlog.txt" is found.
    char fn[100];
    fnprepare("earlyharetlog.txt", fn, sizeof(fn));
    FILE *logfd=fopen(fn, "r");
    if (logfd) {
        // Requesting early logs..
        fclose(logfd);
        openLogFile("haretlog.txt");
    }

    outTls = TlsAlloc();
    TlsSetValue(outTls, 0);

    Output("\n===== HaRET %s =====", VERSION);

    init_ehandling();

    // Prep for per-thread output function.
    prepThread();

    Output("Finished initializing output");

    if(InitKMDriver()){
    	Output("Initializing kernel mode driver succeeded");
    }else{
    	Output(C_ERROR "Initializing kernel mode driver FAILED");
    }

    // Bind to DLLs dynamically.
    setup_LateLoading();

    // Detect some system settings
    setupMachineType();

    // Init memory maps.
    setupMemory();

    // Setup variable/command lists.
    setupCommands();

    // Initialize the machine found earlier.
    Output("Initializing for machine '%s'", Mach->name);
    Mach->init();

    // Send banner info to log (if logging on).
    printWelcome();
}
예제 #22
0
LimaStatusCode EntityTrackerXmlLogger::process(
  AnalysisContent& analysis) const
{
  SELOGINIT;
  LDEBUG << "EntityTrackerXmlLogger::process";
  TimeUtils::updateCurrentTime();
  /* permet de récupérer les annotations */
  //AnnotationData* annotationData = static_cast< AnnotationData* >(analysis.getData("AnnotationData"));

  /* recupérer le graph après l'analyse */
  //const LinguisticAnalysisStructure::AnalysisGraph& graph = *(static_cast<LinguisticAnalysisStructure::AnalysisGraph*>(analysis.getData(m_graph)));

  LinguisticMetaData* metadata=static_cast<LinguisticMetaData*>(analysis.getData("LinguisticMetaData"));
  if (metadata == 0) {
      SELOGINIT;
      LERROR << "no LinguisticMetaData ! abort";
      return MISSING_DATA;
  }

  CoreferenceData* corefData=static_cast<CoreferenceData*>(analysis.getData("CoreferenceData"));
  if (corefData == 0) {
      SELOGINIT;
      LERROR << "no CoreferenceData ! abort";
      return MISSING_DATA;
  }

  ofstream out;
  if (!openLogFile(out,metadata->getMetaData("FileName"))) {
    SELOGINIT;
    LERROR << "Can't open log file '" << metadata->getMetaData("FileName") << "'";
    return UNKNOWN_ERROR;
  }

  out << "<coreference>" << endl;
  for (CoreferenceData::const_iterator it=corefData->begin(), 
         it_end=corefData->end(); it != it_end; it++)
  {
    out << "<entity mentions=\"" << (*it).size() << "\">" << endl;
    for (vector<Token>::const_iterator it2=(*it).begin(), it2_end=(*it).end();
         it2 != it2_end; it2++)
    {
      out << "  <entity_mention>" 
          << limastring2utf8stdstring((*it2).stringForm())
          <<"</entity_mention>";
    }
    out << "<entity>" <<endl;
  }
  out.close();

  return SUCCESS_ID;
}
예제 #23
0
/* Function: mdlStart =====================================================
 * Abstract:
 *    This function is called once at start of model execution. If you
 *    have states that should be initialized once, this is the place
 *    to do it.
 */
static void mdlStart(SimStruct *S)
{
  /*
   * Get access to Parameter/Input/Output/DWork/size information
   */
  void *work1 = ssGetPWorkValue(S, 0);

  /*
   * Call the legacy code function
   */
  openLogFile( &work1);

  /* Update the PWorks */
  ssSetPWorkValue(S, 0, work1);
}
예제 #24
0
파일: log.c 프로젝트: Feechka/UOBP
void
openSystemLog (void) {
#if defined(HAVE_SYSLOG_H)
  if (!syslogOpened) {
    openlog(PACKAGE_NAME, LOG_PID, LOG_DAEMON);
    syslogOpened = 1;
  }
#elif defined(WINDOWS)
  if (windowsEventLog == INVALID_HANDLE_VALUE) {
    windowsEventLog = RegisterEventSource(NULL, PACKAGE_NAME);
  }
#elif defined(__MSDOS__)
  openLogFile(PACKAGE_NAME ".log");
#endif /* open system log */
}
예제 #25
0
void TextMessageDlg::newMsg(const TextMessage& msg, bool store)
{
    switch(msg.nMsgType)
    {
    case MSGTYPE_USER :
    {
        QString line = ui.historyTextEdit->addTextMessage(msg);
        ui.newmsgLabel->setText(tr("New message"));

        QString folder = ttSettings->value(SETTINGS_MEDIASTORAGE_USERLOGFOLDER).toString();
        if(store && folder.size())
        {
            User user;
            if(TT_GetUser(ttInst, m_userid, &user))
            {
                if(!m_logFile.isOpen())
                    openLogFile(m_logFile, folder, _Q(user.szNickname));
            }
            writeLogEntry(m_logFile, line);
        }
    }
    break;
    case MSGTYPE_CUSTOM :
    {
        QStringList cmd_msg = getCustomCommand(msg);
        if(cmd_msg.size() >= 2 && cmd_msg[0] == TT_INTCMD_TYPING_TEXT)
        {
            if(cmd_msg[1] == "1")
            {
                ui.newmsgLabel->setText(tr("New message - remote user typing."));
                if(m_remote_typing_id)
                    killTimer(m_remote_typing_id);
                m_remote_typing_id = startTimer(REMOTE_TYPING_DELAY);
            }
            else
            {
                if(m_remote_typing_id)
                    killTimer(m_remote_typing_id);
                m_remote_typing_id = 0;
                ui.newmsgLabel->setText(tr("New message"));
            }
        }
        break;
    }
    default :
        break;
    }
}
예제 #26
0
BOOL MemHeapInit(VOID)
  {
  PVOID pheap;
  if ( DosAllocMem(&pbasemem, CB_HEAPTOTAL, PAG_READ | PAG_WRITE) ||
       DosSubSetMem(pbasemem, DOSSUB_INIT | DOSSUB_SPARSE_OBJ, CB_HEAPTOTAL) ||
       DosSubAllocMem(pbasemem, &pheap, CB_HEAPBLOCK - CB_SUBSETOVHD) ||
       (NULL == (hp = _ucreate(pheap, CB_HEAPBLOCK - CB_SUBSETOVHD,
                               !_BLOCK_CLEAN, _HEAP_REGULAR,
                               heapIncrease, heapDecrease))) ||
       _uopen(hp) )
    return FALSE;
#ifdef DEBUGMEM
  openLogFile();
#endif
  return TRUE;
  }
예제 #27
0
static void rotateLogs()
{
    int err;

    // Can't rotate logs if we're not outputting to a file
    if (g_outputFileName == NULL) {
        return;
    }

    close(g_outFD);

    // Compute the maximum number of digits needed to count up to g_maxRotatedLogs in decimal.
    // eg: g_maxRotatedLogs == 30 -> log10(30) == 1.477 -> maxRotationCountDigits == 2
    int maxRotationCountDigits =
            (g_maxRotatedLogs > 0) ? (int) (floor(log10(g_maxRotatedLogs) + 1)) : 0;

    for (int i = g_maxRotatedLogs ; i > 0 ; i--) {
        char *file0, *file1;

        asprintf(&file1, "%s.%.*d", g_outputFileName, maxRotationCountDigits, i);

        if (i - 1 == 0) {
            asprintf(&file0, "%s", g_outputFileName);
        } else {
            asprintf(&file0, "%s.%.*d", g_outputFileName, maxRotationCountDigits, i - 1);
        }

        err = rename (file0, file1);

        if (err < 0 && errno != ENOENT) {
            perror("while rotating log files");
        }

        free(file1);
        free(file0);
    }

    g_outFD = openLogFile (g_outputFileName);

    if (g_outFD < 0) {
        perror ("couldn't open output file");
        exit(-1);
    }

    g_outByteCount = 0;

}
예제 #28
0
int main(int argc, char **argv){

  int mapLNfill, ii=0;
/*
  Shared memory creation and attachment
  the segment number is stored in lnptr->pid
*/
  shmKey = ftok("../conf/lnfill.conf",'b');  // key unique identifier for shared memory, other programs use include this
  shmid = shmget(shmKey, sizeof (struct lnfill), 0666); // gets the ID of shared memory, size, permissions, create if necessary by changing to  0666 | IPC_CREAT)
  lnptr = shmat (shmid, (void *)0, 0);                              // now link to area so it can be used; struct lnfill pointer char *lnptr
  if (lnptr == (struct lnfill *)(-1)){                              // check for errors
    perror("shmat");
    exit(EXIT_FAILURE);
  }
  
  openLogFile();                  // open log file...based on name
  printoutHead();                 // print file headings in first 2 lines
  //time0 = lnptr->secRunning;      // load time based on what is in shared memory
  time0 = GetTime();      // load time based on what is in shared memory
//    printf("%li time  ",time1);
/*
  Set logging flag on and print out data to file
*/
  //degptr->com2 = 1;               // set daq logging flag on (writing to SHM from this program at start/stop only)
  lnptr->com2 = 5;               // set daq logging flag on (writing to SHM from this program at start/stop only) CAREFUL! com2=1 is shutdown using 5/6 for logging.
  while (lnptr->com2 == 5 ){
    time1 = GetTime()-time0;
    if (time1 % INTERVAL == 0) {
      printoutBody();
//      time0 += INTERVAL;           // keep the time internal to this program..ie, INTERVAL s 
    }
    sleep(1);
  }
  fclose(fileLN);              // close file on disk
/*
   Wrap up the program ending the lnfill-log
*/  
  lnptr->com2 = 6;               // set daq logging flag off (writing to SHM from this program at start/stop only)
  kill(lnptr->pid,SIGALRM);

  shmdt(lnptr); 
  /* Un-mmaping doesn't close the file, so we still need to do that.
   */
  close(mapLNfill);

  return 0;
}
예제 #29
0
static void rotateLogFile (void)
{
	char oldName[1024];
	int count = snprintf (oldName, sizeof (oldName), "%s.1", logFilename);
	if (count >= (int) sizeof (oldName))
	{
		perror ("Error formatting log rotation filename");
		return;
	}
	int result = rename (logFilename, oldName);
	if (result < 0)
	{
		perror ("Error performing log rotation rename");
		return;
	}
	openLogFile();
}
예제 #30
0
파일: devsw.c 프로젝트: RodneyBates/M3Devel
void DevSW_SetLogfile (const char *filename)
{
  closeLogFile ();
  
  if (angelDebugFilename)
    {
      free (angelDebugFilename);
      angelDebugFilename = NULL;
    }
  
  if (filename && *filename)
    {
      angelDebugFilename = strdup (filename);
      if (angelDebugLogEnable)
        openLogFile ();
    }
}