1 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
4 * Smart Common Input Method
6 * Copyright (c) 2002-2005 James Su <suzhe@tsinghua.org.cn>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this program; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22 * Boston, MA 02111-1307 USA
24 * $Id: scim_debug.cpp,v 1.10 2005/08/05 01:54:24 suzhe Exp $
28 #define Uses_SCIM_DEBUG
29 #include "scim_private.h"
41 static _DebugMaskName _debug_mask_names [] =
43 {SCIM_DEBUG_AllMask, "all"},
44 {SCIM_DEBUG_MainMask, "main"},
45 {SCIM_DEBUG_ConfigMask, "config"},
46 {SCIM_DEBUG_IMEngineMask, "imengine"},
47 {SCIM_DEBUG_BackEndMask, "backend"},
48 {SCIM_DEBUG_FrontEndMask, "frontend"},
49 {SCIM_DEBUG_ModuleMask, "module"},
50 {SCIM_DEBUG_UtilityMask, "utility"},
51 {SCIM_DEBUG_IConvMask, "iconv"},
52 {SCIM_DEBUG_LookupTableMask,"lookuptable"},
53 {SCIM_DEBUG_SocketMask, "socket"},
57 uint32 DebugOutput::current_verbose = 0;
58 uint32 DebugOutput::current_mask = 0;
59 uint32 DebugOutput::verbose_level = 0;
60 uint32 DebugOutput::output_mask = ~0;
61 std::ostream * DebugOutput::output_stream = &std::cerr;
63 static std::ofstream __debug_output_file;
66 DebugOutput::DebugOutput (uint32 mask, uint32 verbose)
69 current_verbose = verbose;
72 DebugOutput::DebugOutput (uint32 mask, uint32 verbose)
78 DebugOutput::set_verbose_level (uint32 verbose)
81 (verbose > SCIM_DEBUG_MAX_VERBOSE) ? SCIM_DEBUG_MAX_VERBOSE : verbose;
85 DebugOutput::enable_debug (uint32 debug)
91 DebugOutput::enable_debug_by_name (const String &debug)
93 _DebugMaskName *p = _debug_mask_names;
94 while (p->mask && p->name) {
95 if (String (p->name) == debug) {
96 output_mask |= p->mask;
104 DebugOutput::disable_debug (uint32 debug)
106 output_mask &= (~debug);
110 DebugOutput::disable_debug_by_name (const String &debug)
112 _DebugMaskName *p = _debug_mask_names;
113 while (p->mask && p->name) {
114 if (String (p->name) == debug) {
115 output_mask &= (~(p->mask));
123 DebugOutput::set_output (const String &file)
125 DebugOutput::output_stream = &std::cerr;
127 if (file.length ()) {
128 if (file == String ("stderr") || file == String ("cerr"))
129 DebugOutput::output_stream = &std::cerr;
130 else if (file == String ("stdout") || file == String ("cout"))
131 DebugOutput::output_stream = &std::cout;
132 else if (file == String ("none") || file == String ("off"))
133 DebugOutput::output_stream = 0;
135 __debug_output_file.open (file.c_str ());
136 if (__debug_output_file.is_open ())
137 DebugOutput::output_stream = &__debug_output_file;
143 DebugOutput::serial_number ()
145 static unsigned int serial = 0;
147 snprintf (buf, 63, "<%08u>:", serial ++);
154 vi:ts=4:nowrap:ai:expandtab