示例#1
0
文件: Log.cpp 项目: ruphy/kfunambol
winLog::winLog(bool resetLog, const char* path, const char* name) {

    setLogPath(path);
    setLogName(name);

    // MUST use a wchar_t* logDir to manage correctly international chars.
    // If using char* logDir and UTF-8, fopen() is not working correctly and
    // will fail to open the log file. (with UTF-8... why?)
    // So we use _wfopen() and a wchar_t* logDir.
    StringBuffer logDir;
    logDir.sprintf("%s\\%s", logPath.c_str(), logName.c_str());
    WCHAR* tmp = toWideChar(logDir.c_str());
    wlogDir = tmp;
    delete [] tmp;

    //
    // Test to ensure the log file is writable (only if path is set)
    //
    if (path) {
        logFile = _wfopen(wlogDir.c_str(), TEXT("a+"));
        if (logFile == NULL) {
            WCHAR tmp[512];
            wsprintf(tmp, TEXT("Unable to write log file: \"%s\".\nPlease check your user's permissions."), wlogDir.c_str());
            MessageBox(NULL, tmp, TEXT("Funambol"), MB_SETFOREGROUND | MB_OK);
        }
        else {
            fclose(logFile);

            if (resetLog) {
                reset(FUNAMBOL_HEADER);
            }
        }
    }
}
示例#2
0
void UResPoly::UResPolyInit()
{
  setLogName("poly");
  //openLog();
  // create status variables
  createBaseVar();
  verbose = false;
  polysCnt = 0;
}
示例#3
0
AREXPORT void ArMutex::setLogNameVar(const char *logName, ...)
{
    char arg[2048];
    va_list ptr;
    va_start(ptr, logName);
    vsnprintf(arg, sizeof(arg), logName, ptr);
    arg[sizeof(arg) - 1] = '\0';
    va_end(ptr);
    return setLogName(arg);
}
示例#4
0
void UVarHist::makeLogName(const char * preName , const char * varName )
{
  if (varLogNameMaxCnt < (int)strlen(preName) + (int)strlen(varName) + 2)
  {
    varLogNameMaxCnt = strlen(preName) + strlen(varName) + 2;
    varLogName = (char*)realloc(varLogName, varLogNameMaxCnt);
  }
  if (varLogName != NULL)
  {
    snprintf(varLogName, varLogNameMaxCnt, "%s%s", preName, varName);
    setLogName(varLogName);
  }
}