mirror of https://github.com/apache/jclouds.git
Issue 374: added slf4j
This commit is contained in:
parent
a453a060a8
commit
a44abb0768
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
(def module-lookup
|
(def module-lookup
|
||||||
{:log4j 'org.jclouds.logging.log4j.config.Log4JLoggingModule
|
{:log4j 'org.jclouds.logging.log4j.config.Log4JLoggingModule
|
||||||
|
:slf4j 'org.jclouds.logging.slf4j.config.SLF4JLoggingModule
|
||||||
:lognull 'org.jclouds.logging.config.NullLoggingModule
|
:lognull 'org.jclouds.logging.config.NullLoggingModule
|
||||||
:ssh 'org.jclouds.ssh.jsch.config.JschSshClientModule
|
:ssh 'org.jclouds.ssh.jsch.config.JschSshClientModule
|
||||||
:enterprise 'org.jclouds.enterprise.config.EnterpriseConfigurationModule
|
:enterprise 'org.jclouds.enterprise.config.EnterpriseConfigurationModule
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
<module>joda</module>
|
<module>joda</module>
|
||||||
<module>bouncycastle</module>
|
<module>bouncycastle</module>
|
||||||
<module>log4j</module>
|
<module>log4j</module>
|
||||||
|
<module>slf4j</module>
|
||||||
<module>jsch</module>
|
<module>jsch</module>
|
||||||
<module>netty</module>
|
<module>netty</module>
|
||||||
<module>enterprise</module>
|
<module>enterprise</module>
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
|
||||||
|
====================================================================
|
||||||
|
Licensed 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.
|
||||||
|
====================================================================
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-project</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../../project/pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<groupId>org.jclouds.driver</groupId>
|
||||||
|
<artifactId>jclouds-slf4j</artifactId>
|
||||||
|
<name>jclouds Log4J Logging Module</name>
|
||||||
|
<description>jclouds Log4J Logging Module</description>
|
||||||
|
|
||||||
|
<!-- bootstrapping: need to fetch the project POM -->
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>jclouds-sona-snapshots-nexus</id>
|
||||||
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
<version>1.6.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,104 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.jclouds.logging.slf4j;
|
||||||
|
|
||||||
|
import org.jclouds.logging.BaseLogger;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link org.apache.slf4j.Logger} implementation of {@link Logger}.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SLF4JLogger extends BaseLogger {
|
||||||
|
private final org.slf4j.Logger logger;
|
||||||
|
private final String category;
|
||||||
|
|
||||||
|
public static class SLF4JLoggerFactory implements LoggerFactory {
|
||||||
|
public Logger getLogger(String category) {
|
||||||
|
return new SLF4JLogger(category, org.slf4j.LoggerFactory.getLogger(category));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SLF4JLogger(String category, org.slf4j.Logger logger) {
|
||||||
|
this.category = category;
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void logTrace(String message) {
|
||||||
|
logger.trace(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
return logger.isTraceEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void logDebug(String message) {
|
||||||
|
logger.debug(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDebugEnabled() {
|
||||||
|
return logger.isDebugEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void logInfo(String message) {
|
||||||
|
logger.info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInfoEnabled() {
|
||||||
|
return logger.isInfoEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void logWarn(String message) {
|
||||||
|
logger.warn(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void logWarn(String message, Throwable e) {
|
||||||
|
logger.warn(message, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWarnEnabled() {
|
||||||
|
return logger.isWarnEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void logError(String message) {
|
||||||
|
logger.error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void logError(String message, Throwable e) {
|
||||||
|
logger.error(message, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isErrorEnabled() {
|
||||||
|
return logger.isErrorEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.jclouds.logging.slf4j.config;
|
||||||
|
|
||||||
|
import org.jclouds.logging.Logger.LoggerFactory;
|
||||||
|
import org.jclouds.logging.config.LoggingModule;
|
||||||
|
import org.jclouds.logging.slf4j.SLF4JLogger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures logging of type {@link SLF4JLogger}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SLF4JLoggingModule extends LoggingModule {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LoggerFactory createLoggerFactory() {
|
||||||
|
return new SLF4JLogger.SLF4JLoggerFactory();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.jclouds.logging.slf4j.config;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.logging.slf4j.SLF4JLogger;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public class SLF4JLoggingModuleTest {
|
||||||
|
|
||||||
|
static class A {
|
||||||
|
@Resource
|
||||||
|
Logger logger = Logger.NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConfigure() {
|
||||||
|
Injector i = Guice.createInjector(new SLF4JLoggingModule());
|
||||||
|
A a = i.getInstance(A.class);
|
||||||
|
assertEquals(a.logger.getClass(), SLF4JLogger.class);
|
||||||
|
assertEquals(a.logger.getCategory(), getClass().getName() + "$A");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -123,7 +123,7 @@ public class QuerySigner implements HttpRequestFilter, RequestSigner {
|
||||||
|
|
||||||
ImmutableSortedSet.Builder<String> builder = ImmutableSortedSet.<String> naturalOrder();
|
ImmutableSortedSet.Builder<String> builder = ImmutableSortedSet.<String> naturalOrder();
|
||||||
for (Entry<String, String> entry : decodedParams.entries())
|
for (Entry<String, String> entry : decodedParams.entries())
|
||||||
builder.add(entry.getKey().toLowerCase() + "=" + Strings2.urlEncode(entry.getValue().toLowerCase()));
|
builder.add(entry.getKey().toLowerCase() + "=" + Strings2.urlEncode(entry.getValue()).toLowerCase());
|
||||||
|
|
||||||
String stringToSign = Joiner.on('&').join(builder.build());
|
String stringToSign = Joiner.on('&').join(builder.build());
|
||||||
if (signatureWire.enabled())
|
if (signatureWire.enabled())
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.predicates.SocketOpen;
|
import org.jclouds.predicates.SocketOpen;
|
||||||
import org.jclouds.savvis.vpdc.domain.Resource;
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
import org.jclouds.savvis.vpdc.domain.Task;
|
import org.jclouds.savvis.vpdc.domain.Task;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.VDC;
|
||||||
import org.jclouds.savvis.vpdc.domain.VM;
|
import org.jclouds.savvis.vpdc.domain.VM;
|
||||||
import org.jclouds.savvis.vpdc.domain.VMSpec;
|
import org.jclouds.savvis.vpdc.domain.VMSpec;
|
||||||
import org.jclouds.savvis.vpdc.predicates.TaskSuccess;
|
import org.jclouds.savvis.vpdc.predicates.TaskSuccess;
|
||||||
|
@ -95,10 +96,19 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
}).getId();
|
}).getId();
|
||||||
|
|
||||||
String networkTierName = Iterables.get(
|
String networkTierName = Iterables.get(
|
||||||
context.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, vpdcId).getAvailableNetworks(), 0)
|
context.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, vpdcId).getAvailableNetworks(), 0)
|
||||||
.getName();
|
.getName();
|
||||||
String name = prefix;
|
String name = prefix;
|
||||||
|
|
||||||
|
// delete any old VM
|
||||||
|
VDC vpdc = context.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, vpdcId);
|
||||||
|
for (Resource resource : vpdc.getResourceEntities()) {
|
||||||
|
if (resource.getName().equals(prefix)) {
|
||||||
|
taskTester.apply(client.removeVMFromVDC(billingSiteId, vpdcId, resource.getId()).getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
CIMOperatingSystem os = Iterables.find(injector.getInstance(Key.get(new TypeLiteral<Set<CIMOperatingSystem>>() {
|
CIMOperatingSystem os = Iterables.find(injector.getInstance(Key.get(new TypeLiteral<Set<CIMOperatingSystem>>() {
|
||||||
})), new Predicate<CIMOperatingSystem>() {
|
})), new Predicate<CIMOperatingSystem>() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue