BROOKLYN-162 - apply org.apache package prefix to logback-includes class
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/7e880618 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/7e880618 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/7e880618 Branch: refs/heads/master Commit: 7e880618fb9191e89bf6ff34e3dc95d1170052e4 Parents: 63e20f7 Author: Alex Heneveld <[email protected]> Authored: Tue Aug 18 14:25:30 2015 +0100 Committer: Alex Heneveld <[email protected]> Committed: Tue Aug 18 14:51:58 2015 +0100 ---------------------------------------------------------------------- .../JcloudsPersistenceThreadDiscriminator.java | 65 -------------------- .../JcloudsPersistenceThreadDiscriminator.java | 65 ++++++++++++++++++++ .../brooklyn/logback-appender-jclouds.xml | 2 +- 3 files changed, 66 insertions(+), 66 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7e880618/usage/logback-includes/src/main/java/brooklyn/logging/JcloudsPersistenceThreadDiscriminator.java ---------------------------------------------------------------------- diff --git a/usage/logback-includes/src/main/java/brooklyn/logging/JcloudsPersistenceThreadDiscriminator.java b/usage/logback-includes/src/main/java/brooklyn/logging/JcloudsPersistenceThreadDiscriminator.java deleted file mode 100644 index a085177..0000000 --- a/usage/logback-includes/src/main/java/brooklyn/logging/JcloudsPersistenceThreadDiscriminator.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.logging; - -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.sift.Discriminator; - -/** - * Discriminates logging events per whether the current thread is named "brooklyn-persister" or not. - * <p> - * Use a {@link ch.qos.logback.classic.sift.SiftingAppender SiftingAppender} and refer to the - * <code>jcloudsPersistSwitch</code> property. The property's value will be either "jclouds-persister", - * for messages logged from the persistence thread, and "jclouds" otherwise. - */ -public class JcloudsPersistenceThreadDiscriminator implements Discriminator<ILoggingEvent> { - - private static final String PERSISTENCE_THREAD = "brooklyn-persister"; - private static final String KEY = "jcloudsPersistSwitch"; - - private boolean isStarted; - - @Override - public String getDiscriminatingValue(ILoggingEvent o) { - return Thread.currentThread().getName().startsWith(PERSISTENCE_THREAD) - ? "persistence" - : "jclouds"; - } - - @Override - public String getKey() { - return KEY; - } - - @Override - public void start() { - isStarted = true; - } - - @Override - public void stop() { - isStarted = false; - } - - @Override - public boolean isStarted() { - return isStarted; - } -} - http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7e880618/usage/logback-includes/src/main/java/org/apache/brooklyn/util/logback/JcloudsPersistenceThreadDiscriminator.java ---------------------------------------------------------------------- diff --git a/usage/logback-includes/src/main/java/org/apache/brooklyn/util/logback/JcloudsPersistenceThreadDiscriminator.java b/usage/logback-includes/src/main/java/org/apache/brooklyn/util/logback/JcloudsPersistenceThreadDiscriminator.java new file mode 100644 index 0000000..5353849 --- /dev/null +++ b/usage/logback-includes/src/main/java/org/apache/brooklyn/util/logback/JcloudsPersistenceThreadDiscriminator.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.brooklyn.util.logback; + +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.sift.Discriminator; + +/** + * Discriminates logging events per whether the current thread is named "brooklyn-persister" or not. + * <p> + * Use a {@link ch.qos.logback.classic.sift.SiftingAppender SiftingAppender} and refer to the + * <code>jcloudsPersistSwitch</code> property. The property's value will be either "jclouds-persister", + * for messages logged from the persistence thread, and "jclouds" otherwise. + */ +public class JcloudsPersistenceThreadDiscriminator implements Discriminator<ILoggingEvent> { + + private static final String PERSISTENCE_THREAD = "brooklyn-persister"; + private static final String KEY = "jcloudsPersistSwitch"; + + private boolean isStarted; + + @Override + public String getDiscriminatingValue(ILoggingEvent o) { + return Thread.currentThread().getName().startsWith(PERSISTENCE_THREAD) + ? "persistence" + : "jclouds"; + } + + @Override + public String getKey() { + return KEY; + } + + @Override + public void start() { + isStarted = true; + } + + @Override + public void stop() { + isStarted = false; + } + + @Override + public boolean isStarted() { + return isStarted; + } +} + http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7e880618/usage/logback-includes/src/main/resources/brooklyn/logback-appender-jclouds.xml ---------------------------------------------------------------------- diff --git a/usage/logback-includes/src/main/resources/brooklyn/logback-appender-jclouds.xml b/usage/logback-includes/src/main/resources/brooklyn/logback-appender-jclouds.xml index 5a76665..757298f 100644 --- a/usage/logback-includes/src/main/resources/brooklyn/logback-appender-jclouds.xml +++ b/usage/logback-includes/src/main/resources/brooklyn/logback-appender-jclouds.xml @@ -23,7 +23,7 @@ Create one rotating log file for each discriminator given by JcloudsPersistenceThreadDiscriminator. --> <appender name="JCLOUDS-SIFT" class="ch.qos.logback.classic.sift.SiftingAppender"> - <discriminator class="brooklyn.logging.JcloudsPersistenceThreadDiscriminator" /> + <discriminator class="org.apache.brooklyn.util.logback.JcloudsPersistenceThreadDiscriminator" /> <sift> <appender name="JCLOUDS-FILE-${jcloudsPersistSwitch}" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${logging.dir:-./}${logging.basename:-brooklyn}.${jcloudsPersistSwitch}.log</file>
