⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logfile.cc

📁 remote installation server.
💻 CC
字号:
/* * PXE daemon - enable the remote booting of PXE enabled machines. * Copyright (C) 2000 Tim Hurman (kano@kano.org.uk) * * 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. * *//****************************************************************************** * logfile.c - a sereis of general event logging procedures                   * ******************************************************************************/#include "logfile.h"/****************************************************************************** * LogFile - constructor                                                      * ******************************************************************************/LogFile::LogFile(){	Open(PXELOGFILE);}/****************************************************************************** * LogFile - constructor                                                      * ******************************************************************************/LogFile::LogFile(const char *filename){	Open(filename);}/****************************************************************************** * LogFile - constructor                                                      * ******************************************************************************/LogFile::~LogFile(){	Close();}/****************************************************************************** * LogOpen - open a log file or die and exit painfully                        * ******************************************************************************/voidLogFile::Open(const char *filename){	/* open the file */	umask(077);	logfile = new std::fstream(filename, std::ios::out|std::ios::app);	if(logfile == NULL)	{		std::cerr << "Error: LogFile::Open:open(): " << strerror(errno) <<"\n";		exit(-1);	}}/****************************************************************************** * LogClose - close the active lof file                                       * ******************************************************************************/voidLogFile::Close(void){	logfile->flush();	logfile->close();}/****************************************************************************** * LogEvent - log an event into the logfile                                   * ******************************************************************************/voidLogFile::Event(int level, const char *where, int count, ...){	time_t currsecs;	char *timestr;	const char *error;	int len;	va_list argp;	char *p;		/* format date and message etc */	currsecs = time(0);	timestr = asctime(localtime(&currsecs));	len = strlen(timestr);	timestr[len-1] = ':';	switch(level)	{	case 1:		error = LEVEL_INFO_C;		break;	case 2:		error = LEVEL_ERR_C;		break;	case 3:		error = LEVEL_EMRG_C;		break;	case 4:		error = LEVEL_FATAL_C;		break;	default:		error = " Unknown: ";		break;	}	/* write info */	*logfile << timestr << " " << error << " " << where << ": ";	/* send any extra args */	va_start(argp, count);	for(len = 0; len < count; len++)	{		p = va_arg(argp, char *);		*logfile << p << " ";	}	va_end(argp);	*logfile << "\n";	logfile->flush();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -