summaryrefslogtreecommitdiff
path: root/src/multilog.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-04-03 03:49:53 +0000
committerMike Buland <eichlan@xagasoft.com>2007-04-03 03:49:53 +0000
commitf4c20290509d7ed3a8fd5304577e7a4cc0b9d974 (patch)
tree13cdf64f7cf134f397a7165b7a3fe0807e37026b /src/multilog.cpp
parent74d4c8cd27334fc7204d5a8773deb3d424565778 (diff)
downloadlibbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.gz
libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.bz2
libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.xz
libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.zip
Ok, no code is left in src, it's all in src/old. We'll gradually move code back
into src as it's fixed and re-org'd. This includes tests, which, I may write a unit test system into libbu++ just to make my life easier.
Diffstat (limited to 'src/multilog.cpp')
-rw-r--r--src/multilog.cpp102
1 files changed, 0 insertions, 102 deletions
diff --git a/src/multilog.cpp b/src/multilog.cpp
deleted file mode 100644
index 143ee89..0000000
--- a/src/multilog.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
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