cFileLogReceiver.cpp
00001
00002
00003
00004
00005 #include "../Headers/cFileLogReceiver.h"
00006 #include <iostream>
00007 #include <fstream>
00008
00009 namespace cAudio
00010 {
00011 cFileLogReceiver::cFileLogReceiver()
00012 {
00013 firsttime = false;
00014 }
00015
00016 cFileLogReceiver::~cFileLogReceiver()
00017 {
00018
00019 }
00020
00021 bool cFileLogReceiver::OnLogMessage(const char* sender, const char* message, LogLevel level, float time)
00022 {
00023 std::ofstream outf;
00024
00025 if(firsttime == false)
00026 {
00027 if( !outf.is_open() )
00028 {
00029
00030 outf.setf( std::ios::fixed );
00031 outf.precision( 3 );
00032 outf.open( "cAudioEngineLog.html", std::ios::out );
00033
00034 if( !outf ){
00035 return false;
00036 }
00037
00038 outf<<"<html>\n";
00039 outf<<"<head>\n";
00040 outf<<"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
00041 outf<<"<title>cAudio Log</title>\n";
00042 outf<<"<style type=\"text/css\">\n";
00043
00044 outf<<"body, html {\n";
00045 outf<<"background: #000000;\n";
00046 outf<<"width: 1000px;\n";
00047 outf<<"font-family: Arial;\n";
00048 outf<<"font-size: 16px;\n";
00049 outf<<"color: #C0C0C0;\n";
00050 outf<<"}\n";
00051
00052 outf<<"h1 {\n";
00053 outf<<"color : #FFFFFF;\n";
00054 outf<<"border-bottom : 1px dotted #888888;\n";
00055 outf<<"}\n";
00056
00057 outf<<"pre {\n";
00058 outf<<"font-family : arial;\n";
00059 outf<<"margin : 0;\n";
00060 outf<<"}\n";
00061
00062 outf<<".box {\n";
00063 outf<<"border : 1px dotted #818286;\n";
00064 outf<<"padding : 5px;\n";
00065 outf<<"margin: 5px;\n";
00066 outf<<"width: 950px;\n";
00067 outf<<"background-color : #292929;\n";
00068 outf<<"}\n";
00069
00070 outf<<".err {\n";
00071 outf<<"color: #EE1100;\n";
00072 outf<<"font-weight: bold\n";
00073 outf<<"}\n";
00074
00075 outf<<".warn {\n";
00076 outf<<"color: #FFCC00;\n";
00077 outf<<"font-weight: bold\n";
00078 outf<<"}\n";
00079
00080 outf<<".crit {\n";
00081 outf<<"color: #BB0077;\n";
00082 outf<<"font-weight: bold\n";
00083 outf<<"}\n";
00084
00085 outf<<".info {\n";
00086 outf<<"color: #C0C0C0;\n";
00087 outf<<"}\n";
00088
00089 outf<<".debug {\n";
00090 outf<<"color: #CCA0A0;\n";
00091 outf<<"}\n";
00092
00093 outf<<"</style>\n";
00094 outf<<"</head>\n\n";
00095
00096 outf<<"<body>\n";
00097 outf<<"<h1>cAudio Log</h1>\n";
00098 outf<<"<h3>" << "2.0.0" << "</h3>\n";
00099 outf<<"<div class=\"box\">\n";
00100 outf<<"<table>\n";
00101
00102 outf.flush();
00103
00104 }
00105 firsttime = true;
00106 }
00107 else
00108 {
00109 outf.open( "cAudioEngineLog.html", std::ios::out | std::ios::app );
00110
00111 if( !outf ){
00112 return false;
00113 }
00114
00115 outf<<"<tr>\n";
00116 outf<<"<td width=\"100\">";
00117 outf<<time;
00118 outf <<"</td>\n";
00119 outf<<"<td class=\"";
00120
00121 switch( level )
00122 {
00123 case ELL_DEBUG:
00124 outf<<"debug";
00125 break;
00126
00127 case ELL_INFO:
00128 outf<<"info";
00129 break;
00130
00131 case ELL_WARNING:
00132 outf<<"warn";
00133 break;
00134
00135 case ELL_ERROR:
00136 outf<<"err";
00137 break;
00138
00139 case ELL_CRITICAL:
00140 outf<<"crit";
00141 break;
00142
00143 case ELL_COUNT:
00144 outf<<"debug";
00145 break;
00146
00147 default:
00148 outf<<"debug";
00149 }
00150
00151 outf<<"\"><pre>\n";
00152 outf<<message;
00153 outf<<"\n</pre></td>\n";
00154 outf<<"</tr>\n";
00155
00156 outf.flush();
00157
00158 }
00159 outf.close();
00160 return true;
00161 }
00162 };
00163
00164