cAudio 2.3.0
3d Audio Engine
Loading...
Searching...
No Matches
cFileLogReceiver.cpp
1// Copyright (c) 2008-2011 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones, Murat (wolfmanfx) Sari
2// This file is part of the "cAudio Engine"
3// For conditions of distribution and use, see copyright notice in cAudio.h
4
5#include "cFileLogReceiver.h"
6
7#if CAUDIO_COMPILE_WITH_FILE_LOG_RECEIVER == 1
8#include <iostream>
9#include <fstream>
10
11namespace cAudio
12{
13 cFileLogReceiver::cFileLogReceiver(const char *lFilePath) :
14 logFilePath(lFilePath)
15 {
16 firsttime = false;
17 }
18
19 cFileLogReceiver::~cFileLogReceiver()
20 {
21
22 }
23
24 bool cFileLogReceiver::OnLogMessage(const char* sender, const char* message, LogLevel level, float time)
25 {
26 std::ofstream outf;
27
28 if(firsttime == false)
29 {
30 if( !outf.is_open() )
31 {
32 // Reset log file
33 outf.setf( std::ios::fixed );
34 outf.precision( 3 );
35 outf.open( logFilePath, std::ios::out );
36
37 if( !outf ){
38 return false;
39 }
40
41 outf<<"<html>\n";
42 outf<<"<head>\n";
43 outf<<"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
44 outf<<"<title>cAudio Log</title>\n";
45 outf<<"<style type=\"text/css\">\n";
46
47 outf<<"body, html {\n";
48 outf<<"background: #000000;\n";
49 outf<<"width: 1000px;\n";
50 outf<<"font-family: Arial;\n";
51 outf<<"font-size: 16px;\n";
52 outf<<"color: #C0C0C0;\n";
53 outf<<"}\n";
54
55 outf<<"h1 {\n";
56 outf<<"color : #FFFFFF;\n";
57 outf<<"border-bottom : 1px dotted #888888;\n";
58 outf<<"}\n";
59
60 outf<<"pre {\n";
61 outf<<"font-family : arial;\n";
62 outf<<"margin : 0;\n";
63 outf<<"}\n";
64
65 outf<<".box {\n";
66 outf<<"border : 1px dotted #818286;\n";
67 outf<<"padding : 5px;\n";
68 outf<<"margin: 5px;\n";
69 outf<<"width: 950px;\n";
70 outf<<"background-color : #292929;\n";
71 outf<<"}\n";
72
73 outf<<".err {\n";
74 outf<<"color: #EE1100;\n";
75 outf<<"font-weight: bold\n";
76 outf<<"}\n";
77
78 outf<<".warn {\n";
79 outf<<"color: #FFCC00;\n";
80 outf<<"font-weight: bold\n";
81 outf<<"}\n";
82
83 outf<<".crit {\n";
84 outf<<"color: #BB0077;\n";
85 outf<<"font-weight: bold\n";
86 outf<<"}\n";
87
88 outf<<".info {\n";
89 outf<<"color: #C0C0C0;\n";
90 outf<<"}\n";
91
92 outf<<".debug {\n";
93 outf<<"color: #CCA0A0;\n";
94 outf<<"}\n";
95
96 outf<<"</style>\n";
97 outf<<"</head>\n\n";
98
99 outf<<"<body>\n";
100 outf<<"<h1>cAudio Log</h1>\n";
101 outf<<"<h3>" << "2.3.0" << "</h3>\n";
102 outf<<"<div class=\"box\">\n";
103 outf<<"<table>\n";
104
105 outf.flush();
106
107 }
108 firsttime = true;
109 }
110 else
111 {
112 outf.open( logFilePath, std::ios::out | std::ios::app );
113
114 if( !outf ){
115 return false;
116 }
117
118 outf<<"<tr>\n";
119 outf<<"<td width=\"100\">";
120 outf<<time;
121 outf <<"</td>\n";
122 outf<<"<td class=\"";
123
124 switch( level )
125 {
126 case ELL_DEBUG:
127 outf<<"debug";
128 break;
129
130 case ELL_INFO:
131 outf<<"info";
132 break;
133
134 case ELL_WARNING:
135 outf<<"warn";
136 break;
137
138 case ELL_ERROR:
139 outf<<"err";
140 break;
141
142 case ELL_CRITICAL:
143 outf<<"crit";
144 break;
145
146 case ELL_COUNT:
147 outf<<"debug";
148 break;
149
150 default:
151 outf<<"debug";
152 }
153
154 outf<<"\"><pre>\n";
155 outf<<message;
156 outf<<"\n</pre></td>\n";
157 outf<<"</tr>\n";
158
159 outf.flush();
160
161 }
162 outf.close();
163 return true;
164 }
165};
166
167#endif
168
169
170
171
Main namespace for the entire cAudio library.
Definition: cAudioCapture.h:16