log.h中的**:
#pragma once
#define max_buffer_length 1024
class clog
; tchar currentfilename[max_path] = ;
file* fileptr = null;
tchar debuglog[max_buffer_length] = ;
va_list ap;
tchar log[max_buffer_length] = ;
va_start(ap,data);
_vstprintf(log,data,ap);
va_end(ap);
getlocaltime(&systemtime);
_sntprintf(currentdate,32,_t("%d-%d-%d %d:%d:%d"),
systemtime.wyear,
systemtime.wmonth,
systemtime.wday,
systemtime.whour,
systemtime.wminute,
systemtime.wsecond);
_sntprintf(currentfilename,max_path,_t("log_%d-%d-%d %d.log"),
systemtime.wyear,
systemtime.wmonth,
systemtime.wday,
systemtime.whour);
fileptr = _tfopen(currentfilename,_t("a"));
if(!fileptr)
return false;
_ftprintf(fileptr,_t("[%s] %s\n"),currentdate,log);
_sntprintf(debuglog,max_buffer_length,_t("[%s] %s\n"),currentdate,log);
fflush(fileptr);
fclose(fileptr);
outputdebugstring(debuglog);
_tprintf(_t("%s"),debuglog);
return true;
}};
測試**:(忽略上下文)
......
clog::writelog(_t("測試日誌:%d,%s"),1,"abcdef");
clog::writelog(_t("測試日誌:%d,%s"),2,"啊哦額");
......
XLog 乙個簡易的日誌列印框架
乙個簡易的日誌列印框架 支援列印策略自定義,預設提供2種策略 logcat列印和磁碟列印 列印debug資訊和json日誌 列印xml資訊 列印出錯資訊 列印debug資訊和json日誌 列印xml資訊 列印出錯資訊 目前支援主流開發工具androidstudio的使用,直接配置build.grad...
實現乙個簡易的執行緒池。
定義四個類 乙個內部類 乙個任務類 乙個測試類 乙個執行緒池類包含乙個內部類。任務類 任務類,檢查埠。author administrator public class scannertask public void starttask catch unknownhostexception e ca...
基於koajs的乙個簡易Excel生成服務
運營人員需要將後台的 匯出成excel,由於後端的同學忙於其他事情,想著是不是可以自己做乙個服務來生成。了解到有node xlsx這樣的工具以後就開工了。後台選用了koa,因為非常輕巧,寫個介面只需要幾行 this.body hello console.log listening on port 3...