View Javadoc
1   /*
2     (C) Copyright IBM Corp. 2006, 2009
3   
4     THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
5     ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
6     CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
7   
8     You can obtain a current copy of the Eclipse Public License from
9     http://www.opensource.org/licenses/eclipse-1.0.php
10  
11    @author : Alexander Wolf-Reber, IBM, a.wolf-reber@de.ibm.com
12   * 
13   * Change History
14   * Flag       Date        Prog         Description
15   *------------------------------------------------------------------------------- 
16   * 1565892    2006-11-15  lupusalex    Make SBLIM client JSR48 compliant
17   * 1745282    2007-06-29  ebak         Uniform time stamps for log files
18   * 2003590    2008-06-30  blaschke-oss Change licensing from CPL to EPL
19   * 2524131    2009-01-21  raman_arora  Upgrade client to JDK 1.5 (Phase 1)
20   */
21  
22  package org.sentrysoftware.wbem.sblim.cimclient.internal.logging;
23  
24  /*-
25   * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
26   * WBEM Java Client
27   * ჻჻჻჻჻჻
28   * Copyright (C) 2023 Sentry Software
29   * ჻჻჻჻჻჻
30   * This program is free software: you can redistribute it and/or modify
31   * it under the terms of the GNU Lesser General Public License as
32   * published by the Free Software Foundation, either version 3 of the
33   * License, or (at your option) any later version.
34   *
35   * This program is distributed in the hope that it will be useful,
36   * but WITHOUT ANY WARRANTY; without even the implied warranty of
37   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
38   * GNU General Lesser Public License for more details.
39   *
40   * You should have received a copy of the GNU General Lesser Public
41   * License along with this program.  If not, see
42   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
43   * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
44   */
45  
46  import java.text.MessageFormat;
47  import java.util.logging.Formatter;
48  import java.util.logging.LogRecord;
49  
50  /**
51   * Class LogFormatter implements the formatting algorithm for our console log.
52   * 
53   */
54  public class LogFormatter extends Formatter {
55  
56  	private final String iLineSeparator = System.getProperty("line.separator");
57  
58  	/**
59  	 * Ctor.
60  	 */
61  	public LogFormatter() {
62  		super();
63  	}
64  
65  	/*
66  	 * (non-Javadoc)
67  	 * 
68  	 * @see java.util.logging.Formatter#format(java.util.logging.LogRecord)
69  	 */
70  	@Override
71  	public String format(LogRecord pRecord) {
72  		StringBuffer buffer = new StringBuffer();
73  		buffer.append(TimeStamp.format(pRecord.getMillis()));
74  		buffer.append(" >");
75  		buffer.append(String.valueOf(pRecord.getThreadID()));
76  		buffer.append("< ");
77  		// buffer.append(iLineSeparator);
78  		buffer.append(pRecord.getLevel().getName());
79  		buffer.append(": ");
80  		buffer.append(MessageFormat.format(pRecord.getMessage(), pRecord.getParameters()));
81  		buffer.append(this.iLineSeparator);
82  		return buffer.toString();
83  	}
84  }