iOS NSlog去掉時間戳及其他輸出樣式

2021-08-22 12:15:09 字數 937 閱讀 3255

1.一般專案中我的nslog會在prefix.pch檔案新增如下**,已保證在非除錯狀態下nslog不工作

#ifdef debug

#define nslog(...) nslog(__va_args__)

#else

#define nslog(...)

#endif

2.在專案中如果沒做任何處理的話會輸出如下資訊,前面有乙個時間戳

2014-11-0708:25:40.885zcsy[673:8937]cell的高度258.684998

我們修改下巨集如下:

#ifdef debug

#define nslog(format, ...) fprintf(stderr,"%s\n",[[nsstring stringwithformat:format, ##__va_args__] utf8string]);

#else

#define nslog(...)

#endif

經過上面的修改我們可以輸出 純淨的內容如下:

cell的高度258.684998

#ifdef debug

#define nslog(format, ...) fprintf(stderr,"%s:%d\t%s\n",[[[nsstring stringwithutf8string:__file__] lastpathcomponent] utf8string], __line__, [[nsstring stringwithformat:format, ##__va_args__] utf8string]);

#else

#define nslog(...)

#endif

這樣我們的輸出就是這樣:

objective-c

它會輸出檔名,和列印的具體行號

dealitemcell.m:307cell的高度258.684998

時間戳 時間

由於團隊業務做的是國際專案,就無法避免乙個問題 時區問題,很多業務都是跟時間有關。一些時間的對比,時間的展示,都會涉及到時區和時間戳,所以花點時間來簡單總結一下 時間戳定義 0時區1970年1月1日到現在的毫秒數,所以全世界同一時刻的時間戳都是一樣的。北京時間對應時間戳 unix 0時區對應時間的時...

js獲取時間戳 時間戳轉時間

1 var timestamp date.parse new date 精準到秒2 var timestamp new date valueof 精準到毫秒3.var timestamp new date gettime 精準到毫秒1 var a new date tolocaledatestrin...

獲取時間戳,幾個時間點的時間戳

最近的上上上乙個週日24點時間戳 threeweekago strtotime date y m d time 2 week date w time day 1 day 最近的上上乙個週日24點時間戳 twoweekago strtotime date y m d time 1 week date ...