Fix transcript in transfer window.
[cyberduck.git] / source / ch / cyberduck / ui / cocoa / logging / SystemLogAppender.java
blob819e8ae548961168848004702cc8241839f16a62
1 package ch.cyberduck.ui.cocoa.logging;
3 /*
4 * Copyright (c) 2012 David Kocher. All rights reserved.
5 * http://cyberduck.ch/
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * Bug fixes, suggestions and comments should be sent to:
18 * dkocher@cyberduck.ch
21 import ch.cyberduck.binding.foundation.FoundationKitFunctionsLibrary;
23 import org.apache.log4j.AppenderSkeleton;
24 import org.apache.log4j.Layout;
25 import org.apache.log4j.Level;
26 import org.apache.log4j.spi.LoggingEvent;
28 /**
29 * Redirect to NSLog(). Logs an error message to the Apple System Log facility.
31 * @version $Id$
33 public class SystemLogAppender extends AppenderSkeleton {
35 @Override
36 protected void append(final LoggingEvent event) {
37 final StringBuilder buffer = new StringBuilder();
38 buffer.append(layout.format(event));
39 if(layout.ignoresThrowable()) {
40 final String[] trace = event.getThrowableStrRep();
41 if(trace != null) {
42 buffer.append(Layout.LINE_SEP);
43 for(final String t : trace) {
44 buffer.append(t).append(Layout.LINE_SEP);
48 FoundationKitFunctionsLibrary.NSLog(buffer.toString());
51 @Override
52 public synchronized void doAppend(final LoggingEvent event) {
53 if(event.getLevel().isGreaterOrEqual(Level.ERROR)) {
54 // Restrict to error level
55 super.doAppend(event);
59 @Override
60 public void close() {
64 @Override
65 public boolean requiresLayout() {
66 return true;