Merge pull request #64 in ITERATE/cyberduck from feature/windows/9074 to master
[cyberduck.git] / source / ch / cyberduck / ui / cocoa / logging / SystemLogAppender.java
blobb43b13d982d8c7fbcb1aad52b73322adea199876
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.spi.LoggingEvent;
27 /**
28 * Redirect to NSLog(). Logs an error message to the Apple System Log facility.
30 * @version $Id$
32 public class SystemLogAppender extends AppenderSkeleton {
34 @Override
35 protected void append(final LoggingEvent event) {
36 final StringBuilder buffer = new StringBuilder();
37 buffer.append(layout.format(event));
38 if(layout.ignoresThrowable()) {
39 final String[] trace = event.getThrowableStrRep();
40 if(trace != null) {
41 buffer.append(Layout.LINE_SEP);
42 for(final String t : trace) {
43 buffer.append(t).append(Layout.LINE_SEP);
47 FoundationKitFunctionsLibrary.NSLog("%@", buffer.toString());
50 @Override
51 public void close() {
55 @Override
56 public boolean requiresLayout() {
57 return true;