C 簡單的日誌類

2022-09-24 01:21:07 字數 934 閱讀 4593

/*

簡單的日誌記錄類. (日誌而已,何必那麼複雜!!!)

w.j.chang 2013.12.13

說明:(easylog.h)

1, 簡單的單件實現(自動垃圾**)

2, 使用方法:easylog::inst()->log("run...");

3, 日誌記錄結果:run... [2013.12.13 16:38:42 friday]

*/#pragma once

#ifndef easy_log_h_8080

#define easy_log_h_8080

#include

#include

#include

#include

class easylog

return _instance.get();

} void log(std::string msg); // 寫日誌的方法

private:

easylog(void){}

virtual ~easylog(void){}

friend class std::auto_ptr;

static std::auto_ptr _instance;

};std::auto_ptr easylog::_instance;

void easylog::log(std::string loginfo)

#endif

用法如下:

#include "easylog.h"

int main()不只是main函式中,任何地方只要include標頭檔案就可以用。

主要是輔助除錯,特別是寫dll程式的時候比較實用。可以加個巨集控制。在發布的時候關掉日誌功能。

#include "easylog.h"

#define easylog 1

int main()

c 簡單日誌類檔案

ifndef logger h define logger h define log file logger.log enum log level enum log mode extern int fmtwrite int fd,const char fmt,將格式化的內容寫入到檔案 extern ...

簡單寫日誌類

public class logmanager 設定要寫入日誌的屬性 if system.io.file.exists sfileurl filestream fs new filestream sfileurl,filemode.openorcreate,fileaccess.write stre...

乙個簡單可用的C 日誌類

少廢話,直接看東西。pragma once include define log buffer size 1024 class logwriter include logwriter.h include include include include logwriter logwriter cons...