Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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]")));
}
Ejemplo n.º 3
0
ChatLog::ChatLog(const wxString& logname)
    : m_logname(logname)
    , m_active(false)
    , m_logfile()
{
	wxLogMessage(_T( "ChatLog::ChatLog( %s )" ), logname.c_str());
	if (LogEnabled()) {
		m_active = SetLogFile(logname);
	}
}
Ejemplo n.º 4
0
ChatLog::ChatLog( const wxString& server, const wxString& room ):
    m_server( server ),
    m_room( room ),
    m_active ( LogEnabled() ),
    m_logfile ( )
{
#ifdef __WXMSW__
    m_server.Replace( wxT( ":" ), wxT( "_" ) ) ;
#endif
    wxLogMessage( _T( "ChatLog::ChatLog( %s, %s )" ), m_server.c_str(), m_room.c_str() ) ;
    m_active = OpenLogFile();
}
Ejemplo n.º 5
0
bool ChatLog::AddMessage( const wxString& text )
{
    if ( !LogEnabled() || ! m_active ) {
        return true;
    }
    else if ( !m_logfile.IsOpened() ) {
        m_active = OpenLogFile();
    }
    if ( m_active )
    {
        return WriteLine( LogTime() + _T( " " ) + text + wxTextBuffer::GetEOL() );
    }
    else return false;
}
Ejemplo n.º 6
0
bool ChatLog::AddMessage(const wxString& text)
{
	if (!LogEnabled()) {
		return true;
	}
	if (!m_active) { //logging is enabled, logfile should be writeable
		return false;
	}
	const bool res = m_logfile.Write(text + wxTextBuffer::GetEOL(), wxConvUTF8);
	if (!res) {
		wxLogWarning(_T("Couldn't write to %s"), m_logname.c_str());
		m_logfile.Close();
	}
	return res;
}