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.metricshub.wbem.sblim.cimclient.internal.logging;
23  
24  /*-
25   * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
26   * WBEM Java Client
27   * ჻჻჻჻჻჻
28   * Copyright 2023 - 2025 MetricsHub
29   * ჻჻჻჻჻჻
30   * Licensed under the Apache License, Version 2.0 (the "License");
31   * you may not use this file except in compliance with the License.
32   * You may obtain a copy of the License at
33   *
34   *      http://www.apache.org/licenses/LICENSE-2.0
35   *
36   * Unless required by applicable law or agreed to in writing, software
37   * distributed under the License is distributed on an "AS IS" BASIS,
38   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39   * See the License for the specific language governing permissions and
40   * limitations under the License.
41   * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
42   */
43  
44  import java.text.MessageFormat;
45  import java.util.logging.Formatter;
46  import java.util.logging.LogRecord;
47  
48  /**
49   * Class LogFormatter implements the formatting algorithm for our console log.
50   *
51   */
52  public class LogFormatter extends Formatter {
53  	private final String iLineSeparator = System.getProperty("line.separator");
54  
55  	/**
56  	 * Ctor.
57  	 */
58  	public LogFormatter() {
59  		super();
60  	}
61  
62  	/*
63  	 * (non-Javadoc)
64  	 *
65  	 * @see java.util.logging.Formatter#format(java.util.logging.LogRecord)
66  	 */
67  	@Override
68  	public String format(LogRecord pRecord) {
69  		StringBuffer buffer = new StringBuffer();
70  		buffer.append(TimeStamp.format(pRecord.getMillis()));
71  		buffer.append(" >");
72  		buffer.append(String.valueOf(pRecord.getThreadID()));
73  		buffer.append("< ");
74  		// buffer.append(iLineSeparator);
75  		buffer.append(pRecord.getLevel().getName());
76  		buffer.append(": ");
77  		buffer.append(MessageFormat.format(pRecord.getMessage(), pRecord.getParameters()));
78  		buffer.append(this.iLineSeparator);
79  		return buffer.toString();
80  	}
81  }