jamulus/src/serverlogging.h

132 lines
3.9 KiB
C
Raw Normal View History

2009-05-24 13:22:12 +02:00
/******************************************************************************\
* Copyright (c) 2004-2009
*
* Author(s):
* Volker Fischer
*
******************************************************************************
*
* 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
*
\******************************************************************************/
#if !defined ( SERVERLOGGING_HOIHOKIH83JH8_3_43445KJIUHF1912__INCLUDED_ )
#define SERVERLOGGING_HOIHOKIH83JH8_3_43445KJIUHF1912__INCLUDED_
2009-06-06 13:34:24 +02:00
#include <qimage.h>
2009-05-24 13:22:12 +02:00
#include <qpainter.h>
#include <qdatetime.h>
#include <qhostaddress.h>
#include <qfile.h>
#include <qstring.h>
2009-06-06 12:07:01 +02:00
#include <qtimer.h>
2009-05-24 13:22:12 +02:00
#include "global.h"
2009-06-06 10:19:24 +02:00
#include "util.h"
/* Definitions ****************************************************************/
// number of history items to store
#define NUM_ITEMS_HISTORY 600
2009-05-24 13:22:12 +02:00
/* Classes ********************************************************************/
2009-06-06 12:07:01 +02:00
class CHistoryGraph : public QObject
2009-06-05 19:59:19 +02:00
{
2009-06-06 12:07:01 +02:00
Q_OBJECT
2009-06-05 19:59:19 +02:00
public:
enum EHistoryItemType
{
HIT_LOCAL_CONNECTION,
HIT_REMOTE_CONNECTION,
HIT_SERVER_STOP
};
2009-06-06 12:07:01 +02:00
CHistoryGraph();
void Start ( const QString& sNewFileName );
void Add ( const QDateTime& newDateTime, const EHistoryItemType curType );
void Add ( const QDateTime& newDateTime, const QHostAddress ClientInetAddr );
2009-06-06 12:07:01 +02:00
void Update();
2009-06-06 10:19:24 +02:00
protected:
struct SHistoryData
{
QDateTime DateTime;
EHistoryItemType Type;
};
2009-06-06 08:17:50 +02:00
void DrawFrame ( const int iNewNumTicksX );
void AddMarker ( const SHistoryData& curHistoryData );
2009-06-05 22:22:47 +02:00
void Save ( const QString sFileName );
2009-06-05 19:59:19 +02:00
2009-06-06 12:07:01 +02:00
bool bDoHistory;
2009-06-05 22:22:47 +02:00
int iYAxisStart;
int iYAxisEnd;
int iNumTicksX;
int iNumTicksY;
int iGridFrameOffset;
int iGridWidthWeekend;
2009-06-05 22:22:47 +02:00
int iTextOffsetToGrid;
int iTextOffsetX;
2009-06-09 22:06:24 +02:00
int iXAxisTextHeight;
int iMarkerSizeNewCon;
int iMarkerSizeServSt;
2009-06-05 22:22:47 +02:00
int iXSpace;
int iYSpace;
QFont AxisFont;
QColor PlotBackgroundColor;
QColor PlotFrameColor;
QColor PlotGridColor;
QColor PlotTextColor;
QColor PlotMarkerNewColor;
QColor PlotMarkerNewLocalColor;
2009-06-05 22:22:47 +02:00
QColor PlotMarkerStopColor;
QDate curDate;
2009-06-06 13:34:24 +02:00
QImage PlotPixmap;
2009-06-05 22:22:47 +02:00
QRect PlotCanvasRect;
QRect PlotGridFrame;
2009-06-06 10:19:24 +02:00
QString sFileName;
2009-06-06 12:07:01 +02:00
QTimer TimerDailyUpdate;
2009-06-06 10:19:24 +02:00
CFIFO<SHistoryData> vHistoryDataFifo;
2009-06-06 12:07:01 +02:00
public slots:
void OnTimerDailyUpdate() { Update(); }
2009-06-05 19:59:19 +02:00
};
2009-05-24 13:22:12 +02:00
class CServerLogging
{
public:
2009-06-06 12:07:01 +02:00
CServerLogging() : bDoLogging ( false ),
File ( DEFAULT_LOG_FILE_NAME ) {}
virtual ~CServerLogging();
void Start ( const QString& strLoggingFileName );
2009-06-06 12:07:01 +02:00
void EnableHistory ( const QString& strHistoryFileName );
void AddNewConnection ( const QHostAddress& ClientInetAddr );
void AddServerStopped();
void ParseLogFile ( const QString& strFileName );
protected:
void operator<< ( const QString& sNewStr );
QString CurTimeDatetoLogString();
2009-06-05 22:22:47 +02:00
CHistoryGraph HistoryGraph;
bool bDoLogging;
QFile File;
2009-05-24 13:22:12 +02:00
};
#endif /* !defined ( SERVERLOGGING_HOIHOKIH83JH8_3_43445KJIUHF1912__INCLUDED_ ) */