UINT CALLBACK LogThread(void* param) { TCHAR fileName[MAX_PATH]; LogPath(fileName, _T("log")); while ( m_bLoggerRunning || (m_logQueue.size() > 0) ) { if ( m_logQueue.size() > 0 ) { SYSTEMTIME systemTime; GetLocalTime(&systemTime); WIN32_FILE_ATTRIBUTE_DATA fileInformation; GetFileAttributesEx(fileName, GetFileExInfoStandard, &fileInformation); if(logFileParsed != systemTime.wDay || fileInformation.nFileSizeLow > 10485760) { LogRotate(); logFileParsed=systemTime.wDay; LogPath(fileName, _T("log")); } CAutoLock lock(&m_logFileLock); FILE* fp = _tfopen(fileName, _T("a+")); if (fp!=NULL) { SYSTEMTIME systemTime; GetLocalTime(&systemTime); wstring line = GetLogLine(); while (!line.empty()) { fwprintf_s(fp, L"%s", line.c_str()); line = GetLogLine(); } fclose(fp); } else //discard data { wstring line = GetLogLine(); while (!line.empty()) { line = GetLogLine(); } } } if (m_bLoggerRunning) { m_EndLoggingEvent.Wait(1000); //Sleep for 1000ms, unless thread is ending } else { Sleep(1); } } _endthreadex(0); return 0; }
void CIISxpressHttpModule::OpenLog(IHttpContext* pHttpContext) { if (pHttpContext != NULL && m_Config.GetLoggingLevel() >= IISXPRESS_LOGGINGLEVEL_BASIC) { CAtlString installPath; m_Config.GetInstallPath(installPath); if (installPath.GetLength() > 0) { CPathT<CAtlString> LogPath(installPath); LogPath.Append(_T("\\Logs")); if (LogPath.IsDirectory() == FALSE) { ::CreateDirectory(LogPath, NULL); } CAtlString sLogFilePrefix; sLogFilePrefix.LoadString(IDS_LOGFILENAMEPREFIX); CAtlString sAppName; if (GetAppPoolName(pHttpContext, sAppName) == true) { sLogFilePrefix += sAppName; sLogFilePrefix += "-"; } m_Log.Init(LogPath, sLogFilePrefix, _T("log")); } } }
static void mem_block_requeut_fn(struct request_queue* q) { struct request* req = NULL; while(NULL != (req = elv_next_request(q))) { if(req -> sector + req -> current_nr_sectors > get_capacity(req->rq_disk)) { end_request(req,0); // return 0; LogPath(); continue; } // Log("sector:%d,current_nr_sectors:%d",req->sector,req->current_nr_sectors); switch(rq_data_dir(req)) { case READ: { memcpy(req->buffer,g_mem_buf + (req->sector << 9),req->current_nr_sectors << 9); end_request(req,1); break; } case WRITE: { memcpy(g_mem_buf + (req->sector << 9), req->buffer,req->current_nr_sectors << 9); end_request(req,1); break; } default: Log("[Error] Unknown request..."); break; // return 0; } } }
// ---------------------------------------------------------------------------------------------------------- // Remove an item from the collection database using the given path // ---------------------------------------------------------------------------------------------------------- // void CTestCollectionPlugin::RemoveL (const CMPXCollectionPath& aPath) { LOG1(_L("CTestCollectionPlugin::RemoveL")); LogPath( aPath ); CDesCArrayFlat* fp = new (ELeave) CDesCArrayFlat(8); CleanupStack::PushL( fp ); switch( aPath.Levels() ) { case 2: if(aPath.Id() == 14) { // Test0091 iObs->HandleRemove( *fp, KErrNotFound ); } break; case 3: if(aPath.Id() == 212) { // Test0090 fp->AppendL( _L("\\song3121.ts") ); fp->AppendL( _L("\\song3122.ts") ); fp->AppendL( _L("\\song3123.tp") ); iObs->HandleRemove( *fp, KErrNone ); } break; case 4: if(aPath.Id() == 3111) { // Test0088 fp->AppendL( _L("\\song3111.ts") ); iObs->HandleRemove( *fp, KErrNone ); } break; default: User::Panic(_L("CTestCollectionPlugin::RemoveL panic"), 1); // magic number } CleanupStack::PopAndDestroy( fp ); }
static int my_driver_demo_remove(struct device_demo* pdev) { if(!pdev) return -1; LogPath(); return 0; }
static int sm_release(struct gendisk *disk, fmode_t mode) { LogPath(); struct scsi_device* sdev = disk->private_data; if(scsi_block_when_processing_errors(sdev)) scsi_set_medium_removal(sdev, SCSI_REMOVAL_ALLOW); else return -EBUSY; return 0; }
void LogRotate() { CAutoLock lock(&m_logFileLock); TCHAR fileName[MAX_PATH]; LogPath(fileName, _T("log")); try { // Get the last file write date WIN32_FILE_ATTRIBUTE_DATA fileInformation; if (GetFileAttributesEx(fileName, GetFileExInfoStandard, &fileInformation)) { // Convert the write time to local time. SYSTEMTIME stUTC, fileTime; if (FileTimeToSystemTime(&fileInformation.ftLastWriteTime, &stUTC)) { if (SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &fileTime)) { logFileDate = fileTime.wDay; SYSTEMTIME systemTime; GetLocalTime(&systemTime); if(fileTime.wDay == systemTime.wDay && fileInformation.nFileSizeLow <= 10485760) { //file date is today and the file size less then 10MB - no rotation needed return; } } } } } catch (...) {} TCHAR bakFileName[MAX_PATH]; LogPath(bakFileName, _T("bak")); _tremove(bakFileName); _trename(fileName, bakFileName); }
static int sm_probe(struct device* dev) { struct scsi_device *sdp = to_scsi_device(dev); int error = -ENODEV; if(sdp->type != TYPE_MEM) goto OUT; LogPath(); struct gendisk* gd = NULL; gd = alloc_disk(1); if(!gd) { Log("[Error] alloc_disk failed."); return -1; } gd->major = SM_MAJOR; gd->first_minor = 0; gd->fops = &sm_fops; gd->private_data = sdp; sprintf(gd->disk_name,"sm-scsi"); gd->queue = sdp->request_queue; gd->driverfs_dev = &sdp->sdev_gendev; //gd->flags = GENHD_FL_DRIVERFS; if(sdp->removable) gd->flags |= GENHD_FL_REMOVABLE; //dev->p->driver_data = (void*)gd; dev_set_drvdata(dev,(void*)gd); sm_spinup_mem_disk(sdp); sm_read_capacity(sdp); set_capacity(gd,g_mem_capacity >> 9); blk_queue_prep_rq(sdp->request_queue,sm_prep_fn); add_disk(gd); return 0; OUT: return error; }
// Start the job, locking down the program while it runs void JobStart() { sectionitem section; // Change the stage if (Job.stage != JobStageBefore) return; // Can only start when before Job.stage = JobStageRunning; // Record the time now as when the job starts Job.time = GetTickCount(); // Save tasks text from the tasks box to the registry Job.tasks = WindowTextGet(Handle.tasks); RegistryWrite(REGISTRYKEY, REGISTRYPATH, REGISTRYNAME, Job.tasks); // Delete the log file from last time and open a new one string s = LogPath(L"Backup"); DiskDeleteFile(s); Job.log = LogOpen(s, L"Errors"); // Start a new thread that will perform all the tasks BeginThread(Tasks); // Have the thread run the Tasks() function }
static int sm_open(struct block_device *pdev, fmode_t mode) //static int sm_open(struct inode *inode, struct file *filp) { LogPath(); int retval = -ENXIO; #if 1 struct gendisk* disk = pdev->bd_disk; Log("disk:0x%x",disk); struct scsi_device* sdev = disk->private_data; if(!scsi_block_when_processing_errors(sdev)) { goto error_out; } if(!scsi_device_online(sdev)) goto error_out; #endif return 0; error_out: return retval; }
static void InitLog() { std::string strHost = "Proxy(127.0.0.1)"; std::string strLogPath = "./logs/"; std::string strLogInnerShowName = "proxybin"; int iLoglevel = LogRLD::INFO_LOG_LEVEL; int iSchedule = LogRLD::DAILY_LOG_SCHEDULE; int iMaxLogFileBackupNum = 10; boost::filesystem::path currentPath = boost::filesystem::current_path() / CONFIG_FILE_NAME; //判断配置文件是否存在 if (boost::filesystem::exists(currentPath)) { //初始化配置信息 ConfigSt cfg(currentPath.string()); std::string strHostCfg = cfg.GetItem("Log.Host"); if (!strHostCfg.empty()) { strHost = strHostCfg; } std::string strLogPathCfg = cfg.GetItem("Log.LogPath"); if (!strLogPathCfg.empty()) { strLogPath = strLogPathCfg; } std::string strLogLevelCfg = cfg.GetItem("Log.Level"); if (!strLogLevelCfg.empty()) { if (strncasecmp("TRACE", strLogLevelCfg.c_str(), 5) == 0) { iLoglevel = LogRLD::TRACE_LOG_LEVEL; } else if (strncasecmp("DEBUG", strLogLevelCfg.c_str(), 5) == 0) { iLoglevel = LogRLD::DEBUG_LOG_LEVEL; } else if (strncasecmp("INFO", strLogLevelCfg.c_str(), 4) == 0) { iLoglevel = LogRLD::INFO_LOG_LEVEL; } else if (strncasecmp("WARN", strLogLevelCfg.c_str(), 4) == 0) { iLoglevel = LogRLD::WARN_LOG_LEVEL; } else if (strncasecmp("ERROR", strLogLevelCfg.c_str(), 5) == 0) { iLoglevel = LogRLD::ERROR_LOG_LEVEL; } else if (strncasecmp("FATAL", strLogLevelCfg.c_str(), 5) == 0) { iLoglevel = LogRLD::FATAL_LOG_LEVEL; } } std::string strLogInnerShowNameCfg = cfg.GetItem("Log.LogFileName"); if (!strLogInnerShowNameCfg.empty()) { strLogInnerShowName = strLogInnerShowNameCfg; } std::string strScheduleCfg = cfg.GetItem("Log.Schedule"); if (!strScheduleCfg.empty()) { if (strncasecmp("HOURLY", strLogLevelCfg.c_str(), 6) == 0) { iSchedule = LogRLD::HOURLY_LOG_SCHEDULE; } else if (strncasecmp("DAILY", strLogLevelCfg.c_str(), 5) == 0) { iSchedule = LogRLD::DAILY_LOG_SCHEDULE; } else { } } std::string strMaxLogFileBackupNumCfg = cfg.GetItem("Log.FileNum"); if (!strMaxLogFileBackupNumCfg.empty()) { iMaxLogFileBackupNum = atoi(strMaxLogFileBackupNumCfg.c_str()); } } boost::filesystem::path LogPath(strLogPath); std::string strFileName =strLogInnerShowName + ".log"; LogPath = LogPath / strFileName; LogRLD::GetInstance().Init(iLoglevel, strHost, strLogInnerShowName, LogPath.string(), iSchedule, iMaxLogFileBackupNum, PROXY_VERSION); }
// ---------------------------------------------------------------------------------------------------------- // Get the extended properties of the current file (async) // ---------------------------------------------------------------------------------------------------------- // void CTestCollectionPlugin::MediaL (const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs, const TArray<TCapability>& aCaps, CMPXAttributeSpecs* aSpecs) { LOG1(_L("CTestCollectionPlugin::MediaL")); LogPath( aPath ); TMPXOpenMode openMode = aPath.OpenNextMode(); //TInt idIndex = aPath.Levels() - 1; LOG2(_L("TMPXOpendMode=%d"), openMode); LOG2(_L("aAttrs.Count()=%d"), aAttrs.Count()); LOG2(_L("aCaps.Count()=%d"), aCaps.Count()); LOG2(_L("aSpecs=0x%x"), aSpecs); switch( (TInt)aPath.Id(1) ) { case 14: // Test0146 { iObs->HandleMedia(NULL, KErrNone); break; } case 15: // Test0147 { CMPXMedia* media = CMPXMedia::NewL(); CleanupStack::PushL( media ); iObs->HandleMedia(media, KErrNone); CleanupStack::PopAndDestroy( media ); break; } case 16: // Test0148 { CMPXMedia* media = CMPXMedia::NewL(); CleanupStack::PushL( media ); iObs->HandleMedia(media, KErrNotFound); CleanupStack::PopAndDestroy( media ); break; } case 17: // Test0149 { CMPXMedia* media = CMPXMedia::NewL(); CleanupStack::PushL( media ); (*media) = *aSpecs; iObs->HandleMedia(media, KErrNone); CleanupStack::PopAndDestroy( media ); break; } case 990: // Test data for playback framework teests { CMPXMedia* media = CMPXMedia::NewL(); CleanupStack::PushL( media ); switch( (TInt)aPath.Id(2) ) { case 9901: AddAttrbuteL(*media, 9901, _L("song9901"), _L("\\song9901.ts"), aAttrs); AddAttributePlaybackFwTestL(*media, 9901, aAttrs); break; case 9902: AddAttrbuteL(*media, 9902, _L("song9902"), _L("\\song9902.ts"), aAttrs); AddAttributePlaybackFwTestL(*media, 9902, aAttrs); break; case 9903: AddAttrbuteL(*media, 9903, _L("song9903"), _L("\\song9903.ts"), aAttrs); AddAttributePlaybackFwTestL(*media, 9903, aAttrs); break; case 9904: AddAttrbuteL(*media, 9904, _L("song9904"), _L("\\song9904.ts"), aAttrs); AddAttributePlaybackFwTestL(*media, 9904, aAttrs); break; case 9905: AddAttrbuteL(*media, 9905, _L("song9905"), _L("\\song9905.ts"), aAttrs); AddAttributePlaybackFwTestL(*media, 9905, aAttrs); break; case 9906: AddAttrbuteL(*media, 9906, _L("song9906"), _L("\\song9906.ts"), aAttrs); AddAttributePlaybackFwTestL(*media, 9906, aAttrs); break; case 9907: AddAttrbuteL(*media, 9907, _L("song9907"), _L("\\song9907.ts"), aAttrs); AddAttributePlaybackFwTestL(*media, 9907, aAttrs); break; }; iObs->HandleMedia(media, KErrNone); CleanupStack::PopAndDestroy( media ); break; } default: User::Leave( KErrNotFound ); }; }
// ---------------------------------------------------------------------------------------------------------- // Navigates to the given path // ---------------------------------------------------------------------------------------------------------- // void CTestCollectionPlugin::OpenL(const CMPXCollectionPath& aPath, const TArray<TMPXAttribute>& aAttrs, CMPXFilter* aFilter) { LOG1(_L("CTestCollectionPlugin::OpenL")); LogPath( aPath ); TMPXOpenMode openMode = aPath.OpenNextMode(); TInt idIndex = aPath.Levels() - 1; LOG2(_L("TMPXOpendMode=%d"), openMode); LOG2(_L("aFilter=%x"), aFilter); RArray<TInt> supportedIds; CleanupClosePushL(supportedIds); supportedIds.AppendL(KMPXMediaIdContainer); supportedIds.AppendL(KMPXMediaIdGeneral); CMPXMedia* entries = CMPXMedia::NewL(supportedIds.Array()); CleanupStack::PopAndDestroy(&supportedIds); CleanupStack::PushL(entries); entries->SetTObjectValueL<TMPXItemId>(TMPXAttribute(KMPXMediaIdGeneral,EMPXMediaGeneralId), aPath.Id(idIndex)); if(aPath.Levels() == 1) { // Plugin's root level RArray<TInt> ids; CleanupClosePushL( ids ); ids.Append( 11 ); ids.Append( 12 ); ids.Append( 13 ); ids.Append( 990 ); // for Playback Framework Test RArray<TMPXAttribute> attrs; CleanupClosePushL( attrs ); attrs.Append( KMPXMediaGeneralId ); attrs.Append( KMPXMediaGeneralUri ); attrs.Append( KMPXMediaGeneralTitle ); CMPXMediaArray* array=CMPXMediaArray::NewL(); CleanupStack::PushL( array ); const TArray<TMPXAttribute>& tempRef = aAttrs.Count() == 0? attrs.Array() : aAttrs; AddMediaL(*array, ids, tempRef); FilterMediaArray(*array, aFilter); entries->SetCObjectValueL (TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayContents),array); entries->SetTObjectValueL (TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayCount),array->Count()); iObs->HandleOpen (entries, KErrNone); CleanupStack::PopAndDestroy(3, &ids); // attrs, array, ids } else if(aPath.Levels() == 2) { // Opening plugin's root menu TInt topLevId = aPath.Id(1); RArray<TInt> ids; CleanupClosePushL( ids ); RArray<TMPXAttribute> attrs; CleanupClosePushL( attrs ); CMPXMediaArray* array=CMPXMediaArray::NewL(); CleanupStack::PushL( array ); attrs.Append( KMPXMediaGeneralId ); attrs.Append( KMPXMediaGeneralUri ); attrs.Append( KMPXMediaGeneralTitle ); if(topLevId == 11) { ids.Append( 211 ); ids.Append( 212 ); ids.Append( 213 ); } else if(topLevId == 12) { ids.Append( 221 ); } else if(topLevId == 13) { ids.Append( 231 ); ids.Append( 232 ); } else if(topLevId == 990) { ids.Append( 9901 ); ids.Append( 9902 ); ids.Append( 9903 ); ids.Append( 9904 ); ids.Append( 9905 ); ids.Append( 9906 ); ids.Append( 9907 ); } const TArray<TMPXAttribute>& tempRef = aAttrs.Count() == 0? attrs.Array() : aAttrs; AddMediaL(*array, ids, tempRef); FilterMediaArray(*array, aFilter); entries->SetCObjectValueL (TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayContents),array); entries->SetTObjectValueL (TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayCount),array->Count()); iObs->HandleOpen (entries, KErrNone); CleanupStack::PopAndDestroy(3, &ids); // attrs, array, ids } else if(aPath.Levels() == 3) { // Opening plugin's 2nd TInt secLevId = aPath.Id(2); RArray<TInt> ids; CleanupClosePushL( ids ); RArray<TMPXAttribute> attrs; CleanupClosePushL( attrs ); CMPXMediaArray* array=CMPXMediaArray::NewL(); CleanupStack::PushL( array ); attrs.Append( KMPXMediaGeneralId ); attrs.Append( KMPXMediaGeneralUri ); attrs.Append( KMPXMediaGeneralTitle ); switch( secLevId ) { case 211: ids.Append( 3111 ); break; case 212: ids.Append( 3121 ); break; case 213: ids.Append( 3131 ); break; case 221: // Empty break; case 231: ids.Append( 3311 ); break; case 232: ids.Append( 3321 ); break; }; const TArray<TMPXAttribute>& tempRef = aAttrs.Count() == 0? attrs.Array() : aAttrs; AddMediaL(*array, ids, tempRef); FilterMediaArray(*array, aFilter); entries->SetCObjectValueL (TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayContents),array); entries->SetTObjectValueL (TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayCount),array->Count()); iObs->HandleOpen (entries, KErrNone); CleanupStack::PopAndDestroy(3, &ids); // attrs, array, ids } else { User::Leave( KErrNotFound ); } CleanupStack::PopAndDestroy( entries ); }
void my_device_demo_release(struct device* pdev) { LogPath(); }