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: SimpleLogWriter.java,v $
10 * $Revision: 1.7.2.2 $
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 ************************************************************************/
32 import share
.LogWriter
;
34 import java
.io
.PrintWriter
;
35 import java
.text
.DecimalFormat
;
36 import java
.util
.Calendar
;
37 import java
.util
.GregorianCalendar
;
39 public class SimpleLogWriter
extends PrintWriter
implements LogWriter
{
41 boolean m_bLogging
= false;
42 share
.DescEntry entry
= null;
43 share
.Watcher ow
= null;
45 public SimpleLogWriter() {
47 Calendar cal
= new GregorianCalendar();
48 DecimalFormat dfmt
= new DecimalFormat("00");
49 super.println("LOG> Log started " +
50 dfmt
.format(cal
.get(Calendar
.DAY_OF_MONTH
)) + "." +
51 dfmt
.format(cal
.get(Calendar
.MONTH
)) + "." +
52 dfmt
.format(cal
.get(Calendar
.YEAR
)) + " - " +
53 dfmt
.format(cal
.get(Calendar
.HOUR_OF_DAY
)) + ":" +
54 dfmt
.format(cal
.get(Calendar
.MINUTE
)) + ":" +
55 dfmt
.format(cal
.get(Calendar
.SECOND
)));
59 public boolean initialize(share
.DescEntry _entry
, boolean _bLogging
) {
60 m_bLogging
= _bLogging
;
66 public void println(String msg
) {
67 if ((ow
== null) && (entry
!= null))
69 this.ow
= (share
.Watcher
) entry
.UserDefinedParams
.get("Watcher");
83 // special case: ow == null && entry == null
84 System
.out
.println(msg
);
89 super.println("LOG> " + msg
);
94 // super.println(" ++ " + msg);
99 public boolean summary(share
.DescEntry entry
) {
103 public Object
getWatcher() {
107 public void setWatcher(Object watcher
)
111 entry
.UserDefinedParams
.put("Watcher", (share
.Watcher
) watcher
);