merge the formfield patch from ooo-build
[ooovba.git] / transex3 / source / filter / utils / Logger.java
blobd149956d317662c6c1b86e6fb478820c27d33600
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Logger.java,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package com.sun.star.filter.config.tools.utils;
33 //_______________________________________________
34 // imports
36 import java.lang.*;
37 import java.util.*;
39 //_______________________________________________
40 // definition
42 /** can be used to print out some debug messages
43 * and group it into warnings/errors or info statements.
47 public class Logger
49 //___________________________________________
50 // const
52 /** only error message will be shown. */
53 public static final int LEVEL_ERRORS = 1;
55 /** only errors and warnings will be shown. */
56 public static final int LEVEL_WARNINGS = 2;
58 /** enable errors/warnings and some global info
59 * message. */
60 public static final int LEVEL_GLOBALINFOS = 3;
62 /** enable anything! */
63 public static final int LEVEL_DETAILEDINFOS = 4;
65 //___________________________________________
66 // member
68 /** enable/disable different output level.
69 * e.g. warnings/errors/infos */
70 private int m_nLevel;
72 //___________________________________________
73 // ctor
75 /** initialize new debug object with the specified
76 * debug level.
78 * @param nLevel
79 * the new debug level.
80 * See const values LEVEL_xxx too.
82 public Logger(int nLevel)
84 m_nLevel = nLevel;
87 //___________________________________________
88 // interface
90 /** initialize new debug object with a default
91 * debug level.
93 public Logger()
95 m_nLevel = LEVEL_DETAILEDINFOS;
98 //___________________________________________
99 // interface
101 /** prints out an exception ... if the right level is set.
103 * @param ex
104 * the exception object
106 public synchronized void setException(java.lang.Throwable ex)
108 if (m_nLevel >= LEVEL_ERRORS)
110 System.err.println("Exception:\n");
111 ex.printStackTrace();
115 //___________________________________________
116 // interface
118 /** prints out an error ... if the right level is set.
120 * @param sError
121 * the error message.
123 public synchronized void setError(java.lang.String sError)
125 if (m_nLevel >= LEVEL_ERRORS)
126 System.err.println("Error :\t\""+sError+"\"");
129 //___________________________________________
130 // interface
132 /** prints out a warning ... if the right level is set.
134 * @param sWarning
135 * the warning message.
137 public synchronized void setWarning(java.lang.String sWarning)
139 if (m_nLevel >= LEVEL_WARNINGS)
140 System.err.println("Warning :\t\""+sWarning+"\"");
143 //___________________________________________
144 // interface
146 /** prints out a global info message ... if the right level is set.
148 * Global infos should be used to describe a complex operation.
149 * E.g.: loading of a document.
150 * But not for every sub operation like e.g. analyzing lines
151 * during loading the document!
153 * @param sInfo
154 * the info message.
156 public synchronized void setGlobalInfo(java.lang.String sInfo)
158 if (m_nLevel >= LEVEL_GLOBALINFOS)
159 System.out.println("Info :\t\""+sInfo+"\"");
162 //___________________________________________
163 // interface
165 /** prints out a mode detailed info message ... if the right level is set.
167 * Such detailed message are e.g. "analyze line [n] of file ...".
169 * @param sInfo
170 * the info message.
172 public synchronized void setDetailedInfo(java.lang.String sInfo)
174 if (m_nLevel >= LEVEL_DETAILEDINFOS)
175 System.out.println("Detail :\t\""+sInfo+"\"");