Update ooo320-m1
[ooovba.git] / qadevOOo / runner / stats / SimpleLogWriter.java
blobc536ee1763aaa2ed6123de5a02a745062a7b6be8
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: 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 ************************************************************************/
30 package stats;
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() {
46 super(System.out);
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)));
56 super.flush();
59 public boolean initialize(share.DescEntry _entry, boolean _bLogging) {
60 m_bLogging = _bLogging;
61 entry = _entry;
63 return true;
66 public void println(String msg) {
67 if ((ow == null) && (entry != null))
69 this.ow = (share.Watcher) entry.UserDefinedParams.get("Watcher");
70 if (this.ow != null)
72 this.ow.ping();
75 else
77 if (ow != null)
79 this.ow.ping();
81 else
83 // special case: ow == null && entry == null
84 System.out.println(msg);
88 if (m_bLogging) {
89 super.println("LOG> " + msg);
90 super.flush();
92 // else
93 // {
94 // super.println(" ++ " + msg);
95 // super.flush();
96 // }
99 public boolean summary(share.DescEntry entry) {
100 return true;
103 public Object getWatcher() {
104 return this.ow;
107 public void setWatcher(Object watcher)
109 if (watcher != null)
111 entry.UserDefinedParams.put("Watcher", (share.Watcher) watcher);