2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 import share
.LogWriter
;
22 import java
.io
.PrintWriter
;
23 import java
.text
.DecimalFormat
;
24 import java
.util
.Calendar
;
25 import java
.util
.GregorianCalendar
;
27 public class SimpleLogWriter
extends PrintWriter
implements LogWriter
{
29 private boolean m_bLogging
= false;
30 private share
.DescEntry entry
= null;
31 private share
.Watcher ow
= null;
33 public SimpleLogWriter() {
35 Calendar cal
= new GregorianCalendar();
36 DecimalFormat dfmt
= new DecimalFormat("00");
37 super.println("LOG> Log started " +
38 dfmt
.format(cal
.get(Calendar
.DAY_OF_MONTH
)) + "." +
39 dfmt
.format(cal
.get(Calendar
.MONTH
)) + "." +
40 dfmt
.format(cal
.get(Calendar
.YEAR
)) + " - " +
41 dfmt
.format(cal
.get(Calendar
.HOUR_OF_DAY
)) + ":" +
42 dfmt
.format(cal
.get(Calendar
.MINUTE
)) + ":" +
43 dfmt
.format(cal
.get(Calendar
.SECOND
)));
47 public boolean initialize(share
.DescEntry _entry
, boolean _bLogging
) {
48 m_bLogging
= _bLogging
;
55 public void println(String msg
) {
56 if ((ow
== null) && (entry
!= null))
58 this.ow
= (share
.Watcher
) entry
.UserDefinedParams
.get("Watcher");
72 // special case: ow == null && entry == null
73 System
.out
.println(msg
);
78 super.println("LOG> " + msg
);
83 public boolean summary(share
.DescEntry entry
) {
87 public void setWatcher(Object watcher
)
91 entry
.UserDefinedParams
.put("Watcher", watcher
);