1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Logger.java,v $
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 //_______________________________________________
39 //_______________________________________________
42 /** can be used to print out some debug messages
43 * and group it into warnings/errors or info statements.
49 //___________________________________________
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
60 public static final int LEVEL_GLOBALINFOS
= 3;
62 /** enable anything! */
63 public static final int LEVEL_DETAILEDINFOS
= 4;
65 //___________________________________________
68 /** enable/disable different output level.
69 * e.g. warnings/errors/infos */
72 //___________________________________________
75 /** initialize new debug object with the specified
79 * the new debug level.
80 * See const values LEVEL_xxx too.
82 public Logger(int nLevel
)
87 //___________________________________________
90 /** initialize new debug object with a default
95 m_nLevel
= LEVEL_DETAILEDINFOS
;
98 //___________________________________________
101 /** prints out an exception ... if the right level is set.
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 //___________________________________________
118 /** prints out an error ... if the right level is set.
123 public synchronized void setError(java
.lang
.String sError
)
125 if (m_nLevel
>= LEVEL_ERRORS
)
126 System
.err
.println("Error :\t\""+sError
+"\"");
129 //___________________________________________
132 /** prints out a warning ... if the right level is set.
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 //___________________________________________
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!
156 public synchronized void setGlobalInfo(java
.lang
.String sInfo
)
158 if (m_nLevel
>= LEVEL_GLOBALINFOS
)
159 System
.out
.println("Info :\t\""+sInfo
+"\"");
162 //___________________________________________
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 ...".
172 public synchronized void setDetailedInfo(java
.lang
.String sInfo
)
174 if (m_nLevel
>= LEVEL_DETAILEDINFOS
)
175 System
.out
.println("Detail :\t\""+sInfo
+"\"");