]> git.mxchange.org Git - simgear.git/blob - simgear/debug/logstream.cxx
Modified Files:
[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 General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23 #include "logstream.hxx"
24
25 logstream *global_logstream = NULL;
26
27 bool            logbuf::logging_enabled = true;
28 #ifdef _MSC_VER
29    bool         logbuf::has_console = true;
30 #endif
31 sgDebugClass    logbuf::logClass        = SG_NONE;
32 sgDebugPriority logbuf::logPriority     = SG_INFO;
33 streambuf*      logbuf::sbuf            = NULL;
34
35 logbuf::logbuf()
36 {
37 //     if ( sbuf == NULL )
38 //      sbuf = cerr.rdbuf();
39 }
40
41 logbuf::~logbuf()
42 {
43     if ( sbuf )
44             sync();
45 }
46
47 void
48 logbuf::set_sb( streambuf* sb )
49 {
50     if ( sbuf )
51             sync();
52
53     sbuf = sb;
54 }
55
56 void
57 logbuf::set_log_level( sgDebugClass c, sgDebugPriority p )
58 {
59     logClass = c;
60     logPriority = p;
61 }
62
63 void
64 logbuf::set_log_classes (sgDebugClass c)
65 {
66     logClass = c;
67 }
68
69 sgDebugClass
70 logbuf::get_log_classes ()
71 {
72     return logClass;
73 }
74
75 void
76 logbuf::set_log_priority (sgDebugPriority p)
77 {
78     logPriority = p;
79 }
80
81 sgDebugPriority
82 logbuf::get_log_priority ()
83 {
84     return logPriority;
85 }
86
87 void
88 logstream::setLogLevels( sgDebugClass c, sgDebugPriority p )
89 {
90     logbuf::set_log_level( c, p );
91 }
92