| /** |
| * <copyright> |
| * |
| * Copyright (c) 2010 SAP AG. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Reiner Hille-Doering (SAP AG) - initial API and implementation and/or initial documentation |
| * |
| * </copyright> |
| */ |
| |
| package org.eclipse.bpmn2.tools.ecoremerger; |
| |
| import java.util.Date; |
| import java.util.logging.Formatter; |
| import java.util.logging.Handler; |
| import java.util.logging.Level; |
| import java.util.logging.LogRecord; |
| |
| //This custom formatter formats parts of a log record to a single line |
| class SimpleHTMLFormatter extends Formatter { |
| // This method is called for every log records |
| public String format(LogRecord rec) { |
| StringBuffer buf = new StringBuffer(1000); |
| if (!rec.getMessage().startsWith("<")) |
| buf.append("<p>\n"); |
| |
| if (rec.getLevel().intValue() >= Level.WARNING.intValue()) { |
| buf.append("<b>"); |
| buf.append(formatMessage(rec)); |
| buf.append("</b>"); |
| } else { |
| buf.append(formatMessage(rec)); |
| } |
| |
| if (!rec.getMessage().startsWith("<")) |
| buf.append("</p>\n"); |
| return buf.toString(); |
| } |
| |
| // This method is called just after the handler using this |
| // formatter is created |
| public String getHead(Handler h) { |
| return "<HTML>\n<HEAD>\n" + (new Date()) + "\n</HEAD>\n<BODY>\n"; |
| } |
| |
| // This method is called just after the handler using this |
| // formatter is closed |
| public String getTail(Handler h) { |
| return "</PRE></BODY>\n</HTML>\n"; |
| } |
| } |