SysLog::~SysLog() { Debug( "Log", "Log system shutting down" ); // close logfile SetLogfile( (FILE*)NULL ); }
void SysLog::SetLogfileDefault(std::string logPath) { MutexLock l( mMutex ); // TO-DO: make this more platform independent. struct stat dirInfo; if(stat(logPath.c_str(), &dirInfo) != 0) { mkdir(logPath.c_str(), S_IRWXU); } // set initial log system time SetTime( time( NULL ) ); tm t; localtime_r( &mTime, &t ); // open default logfile char filename[ FILENAME_MAX + 1 ]; std::string logFile = logPath + "log_%02u-%02u-%04u-%02u-%02u.log"; snprintf( filename, FILENAME_MAX + 1, logFile.c_str(), t.tm_mday, t.tm_mon + 1, t.tm_year + 1900, t.tm_hour, t.tm_min ); //snprintf( filename, FILENAME_MAX + 1, EVEMU_ROOT "/log/log_%02u-%02u-%04u-%02u-%02u.log", // t.tm_mday, t.tm_mon + 1, t.tm_year + 1900, t.tm_hour, t.tm_min ); if( SetLogfile( filename ) ) Success( "Log", "Opened logfile '%s'.", filename ); else Warning( "Log", "Unable to open logfile '%s': %s", filename, strerror( errno ) ); }
Basic_Log::~Basic_Log() { Debug( mLogFilename.c_str(), "Log system shutting down" ); // close logfile SetLogfile( (FILE*)NULL ); }
bool NewLog::SetLogfile( const char* filename ) { MutexLock l( mMutex ); FILE* file = NULL; if( NULL != filename ) { file = fopen( filename, "w" ); if( NULL == file ) return false; } return SetLogfile( file ); }
bool SysLog::SetLogfile(const char* filename) { MutexLock l( mMutex ); FILE* file = NULL; if( NULL != filename ) { file = fopen( filename, "w" ); #ifdef HAVE_UNISTD_H // Change file owner to nobody:nobody to prevent possible permissions problems. // Used if the server is started with root permissions on a Linux host. fchown(fileno(file), 99, 99); // nobody:nobody fchmod(fileno(file), S_IWUSR | S_IRUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); // -rw-rw-rw- #endif if( NULL == file ) return false; } return SetLogfile( file ); }
void HTML_Log::SetLogfileDefault(std::string logPath) { MutexLock l( mMutex ); // set initial log system time SetTime( time( NULL ) ); tm t; localtime_r( &mTime, &t ); // open default logfile char filename[ FILENAME_MAX + 1 ]; std::string logFile = logPath + "log_%02u-%02u-%04u-%02u-%02u.log"; snprintf( filename, FILENAME_MAX + 1, logFile.c_str(), t.tm_mday, t.tm_mon + 1, t.tm_year + 1900, t.tm_hour, t.tm_min ); //snprintf( filename, FILENAME_MAX + 1, EVEMU_ROOT "/log/log_%02u-%02u-%04u-%02u-%02u.log", // t.tm_mday, t.tm_mon + 1, t.tm_year + 1900, t.tm_hour, t.tm_min ); if( SetLogfile( filename ) ) Success( "Log", "Opened logfile '%s'.", filename ); else Warning( "Log", "Unable to open logfile '%s': %s", filename, strerror( errno ) ); }