Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert logging to JDK logging #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@
<artifactId>plexus-classworlds</artifactId>
<version>2.4</version>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>log</artifactId>
<version>0.124</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
1 change: 0 additions & 1 deletion resolver-integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<version>1.4-SNAPSHOT</version>
</parent>

<groupId>io.airlift.resolver</groupId>
<artifactId>resolver-integration</artifactId>
<packaging>jar</packaging>

Expand Down
12 changes: 3 additions & 9 deletions resolver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<version>1.4-SNAPSHOT</version>
</parent>

<groupId>io.airlift.resolver</groupId>
<artifactId>resolver</artifactId>

<properties>
Expand Down Expand Up @@ -99,20 +98,15 @@
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<groupId>io.airlift</groupId>
<artifactId>log</artifactId>
</dependency>

<!-- for testing -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@


import com.google.common.collect.ImmutableList;
import io.airlift.resolver.internal.ConsoleRepositoryListener;
import io.airlift.resolver.internal.ConsoleTransferListener;
import io.airlift.resolver.internal.Slf4jLoggerManager;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.project.DefaultProjectBuildingRequest;
import org.apache.maven.project.MavenProject;
Expand Down Expand Up @@ -221,7 +218,7 @@ private static PlexusContainer container()
// NOTE: To avoid inconsistencies, we'll use the Thread context class loader exclusively for lookups
container.setLookupRealm(null);

container.setLoggerManager(new Slf4jLoggerManager());
container.setLoggerManager(new JdkLoggerManager());
container.getLoggerManager().setThresholds(Logger.LEVEL_INFO);

return container;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,113 +11,119 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.airlift.resolver.internal;
package io.airlift.resolver;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.airlift.log.Logger;
import org.sonatype.aether.AbstractRepositoryListener;
import org.sonatype.aether.RepositoryEvent;

/**
* A simplistic repository listener that logs events to the console.
*/
public class ConsoleRepositoryListener
class ConsoleRepositoryListener
extends AbstractRepositoryListener
{
private final Logger logger;

public ConsoleRepositoryListener()
{
this(LoggerFactory.getLogger(ConsoleRepositoryListener.class));
}

public ConsoleRepositoryListener(Logger logger)
{
this.logger = logger;
}
private static final Logger log = Logger.get(ConsoleRepositoryListener.class);

@Override
public void artifactDeployed(RepositoryEvent event)
{
logger.debug("Deployed " + event.getArtifact() + " to " + event.getRepository());
log.debug("Deployed %s to %s", event.getArtifact(), event.getRepository());
}

@Override
public void artifactDeploying(RepositoryEvent event)
{
logger.debug("Deploying " + event.getArtifact() + " to " + event.getRepository());
log.debug("Deploying %s to %s", event.getArtifact(), event.getRepository());
}

@Override
public void artifactDescriptorInvalid(RepositoryEvent event)
{
logger.debug("Invalid artifact descriptor for " + event.getArtifact() + ": " + event.getException().getMessage());
log.debug("Invalid artifact descriptor for %s: %s", event.getArtifact(), event.getException().getMessage());
}

@Override
public void artifactDescriptorMissing(RepositoryEvent event)
{
logger.debug("Missing artifact descriptor for " + event.getArtifact());
log.debug("Missing artifact descriptor for %s", event.getArtifact());
}

@Override
public void artifactInstalled(RepositoryEvent event)
{
logger.debug("Installed " + event.getArtifact() + " to " + event.getFile());
log.debug("Installed %s to %s", event.getArtifact(), event.getFile());
}

@Override
public void artifactInstalling(RepositoryEvent event)
{
logger.debug("Installing " + event.getArtifact() + " to " + event.getFile());
log.debug("Installing %s to %s", event.getArtifact(), event.getFile());
}

@Override
public void artifactResolved(RepositoryEvent event)
{
logger.debug("Resolved artifact " + event.getArtifact() + " from " + event.getRepository());
log.debug("Resolved artifact %s from %s", event.getArtifact(), event.getRepository());
}

@Override
public void artifactDownloading(RepositoryEvent event)
{
logger.debug("Downloading artifact " + event.getArtifact() + " from " + event.getRepository());
log.debug("Downloading artifact %s from %s", event.getArtifact(), event.getRepository());
}

@Override
public void artifactDownloaded(RepositoryEvent event)
{
logger.debug("Downloaded artifact " + event.getArtifact() + " from " + event.getRepository());
log.debug("Downloaded artifact %s from %s", event.getArtifact(), event.getRepository());
}

@Override
public void artifactResolving(RepositoryEvent event)
{
logger.debug("Resolving artifact " + event.getArtifact());
log.debug("Resolving artifact %s", event.getArtifact());
}

@Override
public void metadataDeployed(RepositoryEvent event)
{
logger.debug("Deployed " + event.getMetadata() + " to " + event.getRepository());
log.debug("Deployed %s to %s", event.getMetadata(), event.getRepository());
}

@Override
public void metadataDeploying(RepositoryEvent event)
{
logger.debug("Deploying " + event.getMetadata() + " to " + event.getRepository());
log.debug("Deploying %s to %s", event.getMetadata(), event.getRepository());
}

@Override
public void metadataInstalled(RepositoryEvent event)
{
logger.debug("Installed " + event.getMetadata() + " to " + event.getFile());
log.debug("Installed %s to %s", event.getMetadata(), event.getFile());
}

@Override
public void metadataInstalling(RepositoryEvent event)
{
logger.debug("Installing " + event.getMetadata() + " to " + event.getFile());
log.debug("Installing %s to %s", event.getMetadata(), event.getFile());
}

@Override
public void metadataInvalid(RepositoryEvent event)
{
logger.debug("Invalid metadata " + event.getMetadata());
log.debug("Invalid metadata %s", event.getMetadata());
}

@Override
public void metadataResolved(RepositoryEvent event)
{
logger.debug("Resolved metadata " + event.getMetadata() + " from " + event.getRepository());
log.debug("Resolved metadata %s from %s", event.getMetadata(), event.getRepository());
}

@Override
public void metadataResolving(RepositoryEvent event)
{
logger.debug("Resolving metadata " + event.getMetadata() + " from " + event.getRepository());
log.debug("Resolving metadata %s from %s", event.getMetadata(), event.getRepository());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.airlift.resolver.internal;
package io.airlift.resolver;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.airlift.log.Logger;
import org.sonatype.aether.transfer.AbstractTransferListener;
import org.sonatype.aether.transfer.TransferEvent;
import org.sonatype.aether.transfer.TransferResource;
Expand All @@ -26,27 +25,17 @@
/**
* A simplistic transfer listener that logs uploads/downloads.
*/
public class ConsoleTransferListener
class ConsoleTransferListener
extends AbstractTransferListener
{
private final Logger logger;

public ConsoleTransferListener()
{
this(LoggerFactory.getLogger(ConsoleTransferListener.class));
}

public ConsoleTransferListener(Logger logger)
{
this.logger = logger;
}
private static final Logger log = Logger.get(ConsoleTransferListener.class);

@Override
public void transferInitiated(TransferEvent event)
{
String message = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading" : "Downloading";

logger.debug(message + ": " + event.getResource().getRepositoryUrl() + event.getResource().getResourceName());
log.debug("%s: %s%s", message, event.getResource().getRepositoryUrl(), event.getResource().getResourceName());
}

@Override
Expand All @@ -71,19 +60,20 @@ public void transferSucceeded(TransferEvent event)
throughput = " at " + format.format(kbPerSec) + " KB/sec";
}

logger.debug(type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" + len + throughput + ")");
log.debug("%s: %s%s (%s%s)", type, resource.getRepositoryUrl(), resource.getResourceName(), len, throughput);
}
}

@Override
public void transferFailed(TransferEvent event)
{
logger.debug("transfer failed", event.getException());
log.debug(event.getException(), "Transfer failed");
}

@Override
public void transferCorrupted(TransferEvent event)
{
logger.debug("transfer corrupted", event.getException());
log.debug(event.getException(), "Transfer corrupted");
}

protected long toKB(long bytes)
Expand Down
Loading