/* * Paglo Crawler * Copyright (C) 2006-2008 Paglo Labs Inc. All rights reserved. * www.paglo.com * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef DebugC #define DebugC #include #include #include #include #include "Debug.h" #endif //--------------------------------------------------------------------------- extern FILE *_LogHandle; void DebugInit(void) { _DebugLevel = 0; _DebugConf = 0; } //--------------------------------------------------------------------------- static char *DebugFile() { char *Name = strrchr(_DebugFile, '/'); if (Name) { return Name + 1; } Name = strrchr(_DebugFile, '\\'); if (Name) { return Name + 1; } return _DebugFile; } //--------------------------------------------------------------------------- void DebugMesg(char *Format, ...) { va_list Args; char TimeStamp[20]; time_t TimeCurr; struct tm TmTimeCurr; if (_DebugConf & _DebugLevel) { TimeCurr = time(NULL); //localtime_r(&TimeCurr, &TmTimeCurr); gmtime_r(&TimeCurr, &TmTimeCurr); strftime(TimeStamp, 20, "%b %d %T GMT", &TmTimeCurr); fprintf(_LogHandle, "%s -- %s:%d -- ", TimeStamp, DebugFile(), _DebugLine); va_start(Args, Format); vfprintf(_LogHandle, Format, Args); va_end(Args); if (!strchr(Format, '\n')) { fprintf(_LogHandle, "\n"); } fflush(_LogHandle); } } //---------------------------------------------------------------------------