📄 log.cpp
字号:
/*************************************************************************** * Copyright (C) 2005 by Igor Vlassov * * iev@linux-server.cor.ru * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/#include "log.h"bool CLog::Start(char *strLogFiName){ if (fiLog) Stop(); if((fiLog = fopen(strLogFiName,"a+t"))==NULL) { printf("Impossible to create/open log file %s!\n",strLogFiName); return false; } return true;}void CLog::Stop(){// fiLog.Close(); if (fiLog) { fclose(fiLog); fiLog = NULL; }}void CLog::Out(const char *sMsg){ time_t tt; tm *tLocalTime = NULL; time(&tt); tLocalTime = localtime(&tt); printf("%02d.%02d.%04d %02d:%02d %s\n",tLocalTime->tm_mday, tLocalTime->tm_mon+1,tLocalTime->tm_year+1900, tLocalTime->tm_hour, tLocalTime->tm_min, sMsg); if (fiLog) fprintf(fiLog,"%02d.%02d.%04d %02d:%02d %s\n",tLocalTime->tm_mday, tLocalTime->tm_mon+1, tLocalTime->tm_year+1900, tLocalTime->tm_hour, tLocalTime->tm_min, sMsg);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -