日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

系统日子打印记录

發布時間:2023/12/4 windows 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 系统日子打印记录 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#import <Foundation/Foundation.h>//DmLog----------------------------- #define DmLog_TYPE_1 1 //日志打印 1:開/0:關 #define __DmLOGWITHFUNCTION(s, ...) \ NSLog(@"%s : %@",__FUNCTION__,[NSString stringWithFormat:(s), ##__VA_ARGS__])#if DmLog_TYPE_1 #define DmLog_METHOD NSLog(@"DmLog_METHOD:%@:%@-->",[[self class] description],NSStringFromSelector(_cmd)) #define DmLog(...) __DmLOGWITHFUNCTION(__VA_ARGS__) #define DmLog_2(DmLog_STR_2) DmLog_METHOD,DmLog_STR_2 #else#define DmLog_METHOD #define DmLog(...) #define DmLog_2(DmLog_STR_2) #endif#define SystemLogCreate(a) [SystemLog systemLogWithContent:[NSString stringWithFormat:@"%@",a]] //將內容寫入系統日志中@interface SystemLog : NSObject {NSDate *_date;NSString *_filePath;NSString *_content; }- (id)initWithContent:(NSString *)content; + (SystemLog *)systemLogWithContent:(NSString *)content;@end #import "SystemLog.h" #import "CachesManger.h"#define SYSTEMLOG(a,b) [NSString stringWithFormat:@"----------------------------------------------------\n%@\n\n%@\n\n",a,b]@implementation SystemLog- (id)initWithContent:(NSString *)content{if (self == [super init]) {[self createSystemLogFile];[self nowDate];_content = SYSTEMLOG(_date, content);[self saveSystemLogToTxtWithContent:_content];}return self; }+ (SystemLog *)systemLogWithContent:(NSString *)content{return [[self alloc] initWithContent:content]; }/*** 創建systemLog.txt文件*/ - (void)createSystemLogFile{ // NSString *homePath = NSHomeDirectory(); // NSString *systemLogPath = [homePath stringByAppendingPathComponent:@"Documents/DearMob/SystemLog"]; NSString *cachePath = [CachesManger getCachesFilePath];NSString *filePath = [cachePath stringByAppendingPathComponent:@"systemLog.txt"];NSFileManager *fileManager = [NSFileManager defaultManager];BOOL isExists = [fileManager fileExistsAtPath:filePath];if (!isExists){[fileManager createFileAtPath:filePath contents:nil attributes:nil];} // NSFileManager *fileManager = [NSFileManager defaultManager]; // BOOL isExists = [fileManager fileExistsAtPath:filePath]; // if (!isExists) { // [fileManager createDirectoryAtPath:systemLogPath withIntermediateDirectories:YES attributes:nil error:nil]; // [fileManager createFileAtPath:filePath contents:nil attributes:nil]; // }_filePath = filePath; } /*** 獲取當前時間*/ - (void)nowDate{NSDate *date = [NSDate date];NSTimeZone *zone = [NSTimeZone systemTimeZone];NSInteger interval = [zone secondsFromGMTForDate: date];NSDate *localeDate = [date dateByAddingTimeInterval: interval];_date = localeDate; } /*** 保存內容至系統日志中** @param content 需要添加的系統日志內容*/ - (void)saveSystemLogToTxtWithContent:(NSString *)content{NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:_filePath];[fileHandle seekToEndOfFile];NSData *resultData = [content dataUsingEncoding:NSUTF8StringEncoding];[fileHandle writeData:resultData];[fileHandle closeFile]; }@end

?

轉載于:https://www.cnblogs.com/ZhangYuGe/p/4949579.html

總結

以上是生活随笔為你收集整理的系统日子打印记录的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。