예제 #1
0
void LogManager::writeWriteRecord(int transID, int pageID, char* oldData, char* newData) {
	int newLSN = getNextLSN();
	TxnRecord* rec = txnTable.locateTxnRecord(transID);

	writeLogRecord(getNextLSN(), 2, transID, rec->lastLSN, pageID, 0, oldData, newData);
	rec->lastLSN = newLSN;
}
예제 #2
0
void LogManager::writeEndRecord(int transID) {
	int newLSN = getNextLSN();
	TxnRecord* rec = txnTable.locateTxnRecord(transID);

	char empty[16] = {};
	for (int i = 0; i < 16; i++) { empty[i] = 0; }

	writeLogRecord(getNextLSN(), 5, transID, rec->lastLSN, 0, 0, empty, empty);
	rec->lastLSN = newLSN;

	rec->state = 5;
}
예제 #3
0
void LogManager::writeBeginRecord(int transID) {
	txnTable.insertTxnRecord(transID);

	int newLSN = getNextLSN();
	TxnRecord* rec = txnTable.locateTxnRecord(transID);

	char empty[16] = {};
	for (int i = 0; i < 16; i++) { empty[i] = 0; }

	writeLogRecord(newLSN, 1, transID, rec->lastLSN, 0, 0, empty, empty);
	rec->lastLSN = newLSN;

	rec->state = 1;
	rec->firstLSN = newLSN;
}
예제 #4
0
void
logData (int level, LogDataFormatter *formatLogData, const void *data) {
  const char *prefix = NULL;

  if (level & LOG_FLG_CATEGORY) {
    int category = level & LOG_MSK_CATEGORY;

    if (!logCategoryFlags[category]) return;
    level = categoryLogLevel;

    {
      const LogCategoryEntry *ctg = &logCategoryTable[category];

      prefix = ctg->prefix;
    }
  }

  {
    int write = level <= systemLogLevel;
    int print = level <= stderrLogLevel;

    if (write || print) {
      int oldErrno = errno;
      char record[0X1000];

      STR_BEGIN(record, sizeof(record));
      if (prefix) STR_PRINTF("%s: ", prefix);
      {
        size_t sublength = formatLogData(STR_NEXT, STR_LEFT, data);
        STR_ADJUST(sublength);
      }
      STR_END

      if (write) {
        writeLogRecord(record);

#if defined(WINDOWS)
        if (windowsEventLog != INVALID_HANDLE_VALUE) {
          const char *strings[] = {record};
          ReportEvent(windowsEventLog, toWindowsEventType(level), 0, 0, NULL,
                      ARRAY_COUNT(strings), 0, strings, NULL);
        }

#elif defined(__MSDOS__)

#elif defined(__ANDROID__)
        __android_log_write(toAndroidLogPriority(level), PACKAGE_TARNAME, record);

#elif defined(HAVE_SYSLOG_H)
        if (syslogOpened) syslog(level, "%s", record);
#endif /* write system log */
      }

      if (print) {
        FILE *stream = stderr;
        lockStream(stream);

        if (logPrefixStack) {
          const char *prefix = logPrefixStack->prefix;

          if (*prefix) {
            fputs(prefix, stream);
            fputs(": ", stream);
          }
        }

        fputs(record, stream);
        fputc('\n', stream);

        flushStream(stream);
        unlockStream(stream);
      }

      errno = oldErrno;
    }
  }