1 package ch
.cyberduck
.ui
.cocoa
.logging
;
4 * Copyright (c) 2012 David Kocher. All rights reserved.
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
;
29 * Redirect to NSLog(). Logs an error message to the Apple System Log facility.
33 public class SystemLogAppender
extends AppenderSkeleton
{
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();
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());
52 public synchronized void doAppend(final LoggingEvent event
) {
53 if(event
.getLevel().isGreaterOrEqual(Level
.ERROR
)) {
54 // Restrict to error level
55 super.doAppend(event
);
65 public boolean requiresLayout() {