1 /*******************************************************************************
2 * Copyright (c) 2019 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Semantum Oy - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.platform.ui.internal;
14 import java.text.DateFormat;
15 import java.text.SimpleDateFormat;
16 import java.util.Date;
17 import java.util.TimeZone;
19 import org.simantics.platform.ui.SimanticsConsole;
21 import ch.qos.logback.classic.spi.ILoggingEvent;
22 import ch.qos.logback.core.AppenderBase;
24 public class ConsoleAppender extends AppenderBase<ILoggingEvent> {
26 final private SimanticsConsole console;
28 final private DateFormat formatter;
30 ConsoleAppender(SimanticsConsole console) {
31 assert(console != null);
32 this.console = console;
33 formatter = new SimpleDateFormat("dd.LL.yyyy HH:mm:ss.SSS");
34 formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
38 protected void append(ILoggingEvent e) {
39 StringBuilder b = new StringBuilder();
41 b.append(formatter.format(new Date(e.getTimeStamp())));
43 b.append(e.getFormattedMessage());
44 console.write(b.toString());