bool ChatLog::OpenLogFile() { wxLogMessage( _T( "OpenLogFile( ) server = %s, room = %s" ), m_server.c_str(), m_room.c_str() ) ; wxString logFilePath ( GetCurrentLogfilePath() ); if ( LogEnabled() && CreateCurrentLogFolder() ) { m_logfile.Open( logFilePath, wxFile::write_append ); if ( !m_logfile.IsOpened() ) { wxLogWarning( _T( "Can't open log file %s" ), logFilePath.c_str() ) ; customMessageBox( SL_MAIN_ICON, _( "Can't open log file \"" ) + logFilePath + _("\".\nBe sure that there isn't a write protection.\n" ), _( "Log Warning" ) ) ; m_active = false; } else { FillLastLineArray(); wxDateTime now = wxDateTime::Now(); wxString text = _T( "### Session Start at [" ) + now.Format( _T( "%Y-%m-%d %H:%M" ) ) + _T( "]" ) + wxTextBuffer::GetEOL(); return WriteLine( text ); } } return false; }
bool ChatLog::OpenLogFile() { wxLogMessage(_T( "OpenLogFile( ) %s" ), m_logname.c_str()); wxString logFilePath(GetCurrentLogfilePath()); if (!LogEnabled()) { return true; } if (!CreateCurrentLogFolder()) { return false; } if (!wxFile::Exists(logFilePath)) { m_logfile.Create(logFilePath); } else { m_logfile.Open(logFilePath, wxFile::read_write); } if (!m_logfile.IsOpened()) { wxLogWarning(_T( "Can't open log file %s" ), logFilePath.c_str()); m_active = false; return false; } FillLastLineArray(); m_active = true; return AddMessage(wxDateTime::Now().Format(_("### Session Start at [%Y-%m-%d %H:%M]"))); }