summaryrefslogtreecommitdiff
path: root/src/old/multilog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/old/multilog.cpp')
-rw-r--r--src/old/multilog.cpp102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/old/multilog.cpp b/src/old/multilog.cpp
new file mode 100644
index 0000000..143ee89
--- /dev/null
+++ b/src/old/multilog.cpp
@@ -0,0 +1,102 @@
1#include "multilog.h"
2#include <stdio.h>
3#include <time.h>
4#include <string.h>
5#include <stdlib.h>
6
7#include "multilogchannel.h"
8
9MultiLog::MultiLog()
10{
11 lChannel = new LinkedList();
12 rEntry = new RingList( 150 );
13 nEntriesLost = 0;
14}
15
16MultiLog::~MultiLog()
17{
18 int nMax = lChannel->getSize();
19 for( int j = 0; j < nMax; j++ )
20 {
21 ((MultiLogChannel *)lChannel->getAt(j))->closeLog();
22 delete ((MultiLogChannel *)lChannel->getAt(j));
23 }
24 delete lChannel;
25
26 for( int j = 0; j < rEntry->getSize(); j++ )
27 {
28 delete (LogEntry *)rEntry->getAt( j );
29 }
30 delete rEntry;
31}
32/*
33void MultiLog::Log( int nLevel, const char *lpFormat, ...)
34{
35 switch( nLevel )
36 {
37 default:
38 break;
39 }
40 va_list ap;
41 va_start(ap, lpFormat);
42
43 vprintf( lpFormat, ap );
44
45 va_end(ap);
46}*/
47
48void MultiLog::DetailLog( int nLevel, const char *lpFile, int nLine, const char *lpFunction, const char *lpFormat, ...)
49{
50 LogEntry *e = new LogEntry();
51
52 va_list ap;
53 va_start(ap, lpFormat);
54 char *text;
55 vasprintf( &text, lpFormat, ap );
56 va_end(ap);
57
58 time( &e->xTime );
59 e->nLevel = nLevel;
60 e->nLine = nLine;
61 e->lpFile = new char[strlen(lpFile)+1];
62 strcpy( e->lpFile, lpFile );
63 e->lpText = new char[strlen(text)+1];
64 strcpy( e->lpText, text );
65 free( text );
66
67 append( e );
68}
69
70void MultiLog::append( LogEntry *pEntry )
71{
72 rEntry->append( pEntry );
73 if( rEntry->getPushBuf() )
74 {
75 delete (LogEntry *)rEntry->getPushBuf();
76 nEntriesLost++;
77 }
78
79 for( int j = 0; j < lChannel->getSize(); j++ )
80 {
81 ((MultiLogChannel *)lChannel->getAt( j ))->append( pEntry );
82 }
83}
84
85void MultiLog::addChannel( MultiLogChannel *pChannel )
86{
87 lChannel->append( pChannel );
88
89 pChannel->openLog();
90
91 for( int j = 0; j < rEntry->getSize(); j++ )
92 {
93 pChannel->append( (LogEntry *)rEntry->getAt( j ) );
94 }
95}
96
97MultiLog::LogEntry::~LogEntry()
98{
99 delete[] lpFile;
100 delete[] lpText;
101}
102