I thought JvZ was referring to in the impl for log4j but I ack I may be
misreading on this phone. Otherwise: NICE

On Sunday, 16 December 2012, Hervé BOUTEMY wrote:

> Level class is lg4j specific: I can't use it
>
> I didn't find anything usable more specific than int: ideas welcome.
>
> but what I can do is adding javadoc pointing to plexus Logger constants to
> document accepted values
>
> Regards,
>
> Hervé
>
> Le samedi 15 décembre 2012 20:48:15 Jason van Zyl a écrit :
> > I would suggest you use the Level[1] class instead of a raw int for
> setting
> > the level.
> >
> > [1]: http://www.slf4j.org/apidocs/org/apache/log4j/Level.html
> >
> > jvz
> >
> > On 2012-12-15, at 7:57 PM, [email protected] wrote:
> > > Updated Branches:
> > >  refs/heads/master 915b1553f -> 39e11cf2e
> > >
> > > extracted Slf4jConfiguration interface and corresponding implementation
> > > to clearly separate code depending on slf4j binding
> > >
> > > still need to add automatic selection of implementation
> > >
> > > Project: http://git-wip-us.apache.org/repos/asf/maven/repo
> > > Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/39e11cf2
> > > Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/39e11cf2
> > > Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/39e11cf2
> > >
> > > Branch: refs/heads/master
> > > Commit: 39e11cf2e51a41fc47001f0fe59da251dab87587
> > > Parents: 73ffdaf
> > > Author: Hervé Boutemy <[email protected]>
> > > Authored: Sun Dec 16 01:57:36 2012 +0100
> > > Committer: Hervé Boutemy <[email protected]>
> > > Committed: Sun Dec 16 01:57:36 2012 +0100
> > >
> > > ----------------------------------------------------------------------
> > > .../main/java/org/apache/maven/cli/MavenCli.java   |   12 ++-
> > > .../cli/logging/AbstractSlf4jConfiguration.java    |   46 +++++++++++
> > > .../maven/cli/logging/Slf4jConfiguration.java      |   35 ++++++++
> > > .../cli/logging/impl/Slf4jSimpleConfiguration.java |   62
> +++++++++++++++
> > > 4 files changed, 151 insertions(+), 4 deletions(-)
> > > ----------------------------------------------------------------------
> > >
> > >
> > >
> http://git-wip-us.apache.org/repos/asf/maven/blob/39e11cf2/maven-embedder/
> > > src/main/java/org/apache/maven/cli/MavenCli.java
> > > ----------------------------------------------------------------------
> > > diff --git
> > > a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
> > > b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index
> > > e744e65..e3c62f8 100644
> > > --- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
> > > +++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
> > > @@ -39,8 +39,10 @@ import org.apache.maven.InternalErrorException;
> > > import org.apache.maven.Maven;
> > > import org.apache.maven.cli.event.DefaultEventSpyContext;
> > > import org.apache.maven.cli.event.ExecutionEventLogger;
> > > +import org.apache.maven.cli.logging.Slf4jConfiguration;
> > > import org.apache.maven.cli.logging.Slf4jLoggerManager;
> > > import org.apache.maven.cli.logging.Slf4jStdoutLogger;
> > > +import org.apache.maven.cli.logging.impl.Slf4jSimpleConfiguration;
> > > import org.apache.maven.cli.transfer.ConsoleMavenTransferListener;
> > > import org.apache.maven.cli.transfer.QuietMavenTransferListener;
> > > import org.apache.maven.cli.transfer.Slf4jMavenTransferListener;
> > > @@ -131,6 +133,8 @@ public class MavenCli
> > >
> > >     private DefaultSecDispatcher dispatcher;
> > >
> > > +    private Slf4jConfiguration slf4jConfiguration = new
> > > Slf4jSimpleConfiguration(); +
> > >
> > >     public MavenCli()
> > >     {
> > >
> > >         this( null );
> > >
> > > @@ -306,24 +310,24 @@ public class Mav> > Configuration.java new file
> mode 100644
> > > index 0000000..2b2ef6d
> > > --- /dev/null
> > > +++
> > >
> b/maven-embedder/src/main/java/org/apache/maven/cli/logging/AbstractSlf4j
> > > Configuration.java @@ -0,0 +1,46 @@
> > > +package org.apache.maven.cli.logging;
> > > +
> > > +/*
> > > + * 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.
> > > + */
> > > +
> > > +import java.io.File;
> > > +
> > > +import org.slf4j.Logger;
> > > +import org.slf4j.LoggerFactory;
> > > +
> > > +/**
> > > + * Abstract implementation.
> > > + *
> > > + * @author Hervé Boutemy
> > > + */
> > > +public class AbstractSlf4jConfiguration
> > > +    implements Slf4jConfiguration
> > > +{
> > > +    private final Logger logger = LoggerFactory.getLogger(
> > > AbstractSlf4jConfiguration.class ); +
> > > +    public void setRootLoggerLevel( int level )
> > > +    {
> > > +        logger.warn( "setRootLoggerLevel: operation not supported" );
> > > +    }
> > > +
> > > +    public void setLoggerFile( File output )
> > > +    {
> > > +        logger.warn( "setLoggerFile: operation not supported" );
> > > +    }
> > > +}
> > >
> > >
> http://git-wip-us.apache.org/repos/asf/maven/blob/39e11cf2/maven-embedder/
> > > src/main/java/org/apache/maven/cli/logging/Slf4jConfiguration.java
> > > ----------------------------------------------------------------------
> > > diff --git
> > >
> a/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfigur
> > > ation.java
> > >
> b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfigur
> > > ation.java new file mode 100644
> > > index 0000000..c988bd8
> > > --- /dev/null
> > > +++
> > >
> b/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfigur
> > > ation.java @@ -0,0 +1,35 @@
> > > +package org.apache.maven.cli.logging;
> > > +
> > > +/*
> > > + * 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.
> > > + */
> > > +
> > > +import java.io.File;
> > > +
> > > +/**
> > > + * Interface for configuration operations on loggers, which are not
> > > available in slf4j, then require per-slf4f-binding + * implementation.
> > > + *
> > > + * @author Hervé Boutemy
> > > + */
> > > +public interface Slf4jConfiguration
> > > +{
> > > +    void setRootLoggerLevel( int level );
> > > +
> > > +    void setLoggerFile( File output );
> > > +}
> > >
> > >
> http://git-wip-us.apache.org/repos/asf/maven/blob/39e11cf2/maven-embedder/
> > >
> src/main/java/org/apache/maven/cli/logging/impl/Slf4jSimpleConfiguration.j
> > > ava
> ----------------------------------------------------------------------
> > > diff --git
> > >
> a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSim
> > > pleConfiguration.java
> > >
> b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSim
> > > pleConfiguration.java new file mode 100644
> > > index 0000000..c5d60d8
> > > --- /dev/null
> > > +++
> > >
> b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSim
> > > pleConfiguration.java @@ -0,0 +1,62 @@
> > > +package org.apache.maven.cli.logging.impl;
> > > +
> > > +/*
> > > + * 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.
> > > + */
> > > +
> > > +import java.io.File;
> > > +
> > > +import org.apache.maven.cli.logging.AbstractSlf4jConfiguration;
> > > +import org.apache.maven.cli.logging.Slf4jConfiguration;
> > > +import org.apache.maven.execution.MavenExecutionRequest;
> > > +import org.codehaus.plexus.component.annotations.Component;
> > > +
> > > +/**
> > > + * Configuration for slf4j-simple.
> > > + *
> > > + * @author Hervé Boutemy
> > > + */
> > > +@Component( role = Slf4jConfiguration.class )
> > > +public class Slf4jSimpleConfiguration
> > > +    extends AbstractSlf4jConfiguration
> > > +{
> > > +    public void setRootLoggerLevel( int level )
> > > +    {
> > > +        String value = "info";
> > > +        switch ( level )
> > > +        {
> > > +            case MavenExecutionRequest.LOGGING_LEVEL_DEBUG:
> > > +                value = "debug";
> > > +                break;
> > > +
> > > +            case MavenExecutionRequest.LOGGING_LEVEL_INFO:
> > > +                value = "info";
> > > +                break;
> > > +
> > > +            case MavenExecutionRequest.LOGGING_LEVEL_ERROR:
> > > +                value = "error";
> > > +                break;
> > > +        }
> > > +        System.setProperty( "org.slf4j.simpleLogger.defaultLogLevel",
> > > value ); +    }
> > > +
> > > +    public void setLoggerFile( File output )
> > > +    {
> > > +        System.setProperty( "org.slf4j.simpleLogger.logFile",
> > > output.getAbsolutePath() ); +    }
> > > +}
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected] <javascript:;>
> For additional commands, e-mail: [email protected] <javascript:;>
>
>

Reply via email to