1 | /***************************************************************************
|
---|
2 | amclog.cpp - description
|
---|
3 | -------------------
|
---|
4 | begin : Mon Aug 25 2003
|
---|
5 | copyright : (C) 2003 by Martin Merck
|
---|
6 | email : merck@astro.uni-wuerzburg.de
|
---|
7 | ***************************************************************************/
|
---|
8 |
|
---|
9 | /***************************************************************************
|
---|
10 | * *
|
---|
11 | * This program is part of the MAGIC control software for the AMC. *
|
---|
12 | * The software is only intended for use in the MAGIC telescope project *
|
---|
13 | * All rights remain with the author. *
|
---|
14 | ***************************************************************************/
|
---|
15 |
|
---|
16 | #include <qfile.h>
|
---|
17 | #include <qstring.h>
|
---|
18 | #include <qdatetime.h>
|
---|
19 | #include <qregexp.h>
|
---|
20 | #include <qtextstream.h>
|
---|
21 | #include "amclog.h"
|
---|
22 | #include "amcerror.h"
|
---|
23 |
|
---|
24 | AMCLog::AMCLog()
|
---|
25 | {
|
---|
26 | QDateTime theDT = QDateTime::currentDateTime();
|
---|
27 | QDate theDate = theDT.date();
|
---|
28 | QTime theTime = theDT.time();
|
---|
29 | QString qsFileName;
|
---|
30 | qsFileName.sprintf( "/home/amc/data/AMC_%04d_%02d_%02d_%02d_%02d_%02d.log",
|
---|
31 | theDate.year(), theDate.month(), theDate.day(),
|
---|
32 | theTime.hour(), theTime.minute(), theTime.second() );
|
---|
33 | m_qfFile.setName( qsFileName );
|
---|
34 | if( ! m_qfFile.open( IO_WriteOnly ) )
|
---|
35 | {
|
---|
36 | qDebug( "ERROR: Can't open file: %s\n", qsFileName.latin1() );
|
---|
37 | }
|
---|
38 | m_qtsStream.setDevice( &m_qfFile );
|
---|
39 | m_qtsStream << "AMC Log started at: " << theDT.toString() << endl;
|
---|
40 | m_qfFile.flush();
|
---|
41 | }
|
---|
42 |
|
---|
43 | AMCLog::~AMCLog()
|
---|
44 | {
|
---|
45 | QDateTime theDT = QDateTime::currentDateTime();
|
---|
46 | m_qtsStream << "AMC Log closed at: " << theDT.toString() << endl;
|
---|
47 | m_qfFile.close();
|
---|
48 | }
|
---|
49 |
|
---|
50 | void AMCLog::logError( const QString& p_qsMsg1, const AMCError& e )
|
---|
51 | {
|
---|
52 | QDateTime theDT = QDateTime::currentDateTime();
|
---|
53 | m_qtsStream << "ERROR: " << "[ " << theDT.toString() << "]" << endl;
|
---|
54 | m_qtsStream << " " << p_qsMsg1 << endl;
|
---|
55 | m_qtsStream << e.formatError(7) << endl;
|
---|
56 | m_qfFile.flush();
|
---|
57 | }
|
---|
58 |
|
---|
59 | void AMCLog::logWarning( const QString& p_qsMsg1, const QString& p_qsMsg2 )
|
---|
60 | {
|
---|
61 | QDateTime theDT = QDateTime::currentDateTime();
|
---|
62 | m_qtsStream << "[" << theDT.toString() << " " << p_qsMsg1 << "]" << endl;
|
---|
63 | m_qtsStream << QString( p_qsMsg2 ).replace( QRegExp("/012"), "" ) << endl << endl;
|
---|
64 | m_qfFile.flush();
|
---|
65 | }
|
---|
66 |
|
---|
67 | void AMCLog::logInfo( const QString& p_qsMsg1, const QString& p_qsMsg2 )
|
---|
68 | {
|
---|
69 | QDateTime theDT = QDateTime::currentDateTime();
|
---|
70 | m_qtsStream << "[" << theDT.toString() << " " << p_qsMsg1 << "]" << endl;
|
---|
71 | m_qtsStream << QString( p_qsMsg2 ).replace( QRegExp("/012"), "" ) << endl << endl;
|
---|
72 | m_qfFile.flush();
|
---|
73 | }
|
---|
74 |
|
---|
75 |
|
---|