]> git.mxchange.org Git - simgear.git/blob - simgear/debug/logstream.cxx
SG-ified logstream.
[simgear.git] / simgear / debug / logstream.cxx
1 // Stream based logging mechanism.
2 //
3 // Written by Bernie Bright, 1998
4 //
5 // Copyright (C) 1998  Bernie Bright - bbright@c031.aone.net.au
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Library General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // Library General Public License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public
18 // License along with this library; if not, write to the
19 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 // Boston, MA  02111-1307, USA.
21 //
22 // $Id$
23
24 #include "logstream.hxx"
25
26 bool            logbuf::logging_enabled = true;
27 sgDebugClass    logbuf::logClass        = SG_NONE;
28 sgDebugPriority logbuf::logPriority     = SG_INFO;
29 streambuf*      logbuf::sbuf            = NULL;
30
31 logbuf::logbuf()
32 {
33 //     if ( sbuf == NULL )
34 //      sbuf = cerr.rdbuf();
35 }
36
37 logbuf::~logbuf()
38 {
39     if ( sbuf )
40             sync();
41 }
42
43 void
44 logbuf::set_sb( streambuf* sb )
45 {
46     if ( sbuf )
47             sync();
48
49     sbuf = sb;
50 }
51
52 void
53 logbuf::set_log_level( sgDebugClass c, sgDebugPriority p )
54 {
55     logClass = c;
56     logPriority = p;
57 }
58
59 void
60 logstream::setLogLevels( sgDebugClass c, sgDebugPriority p )
61 {
62     logbuf::set_log_level( c, p );
63 }
64