1 package org
.argeo
.slc
.maven
.embedder
;
4 * Copyright 2001-2005 The Apache Software Foundation.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import org
.codehaus
.plexus
.logging
.AbstractLoggerManager
;
20 import org
.codehaus
.plexus
.logging
.Logger
;
21 import org
.codehaus
.plexus
.logging
.LoggerManager
;
22 import org
.codehaus
.plexus
.logging
.console
.ConsoleLogger
;
23 import org
.codehaus
.plexus
.personality
.plexus
.lifecycle
.phase
.Initializable
;
26 * This is a simple logger manager that will only write the logging statements to the console.
28 * Sample configuration:
31 * <implementation>org.codehaus.plexus.logging.ConsoleLoggerManager</implementation>
33 * <threshold>DEBUG</threshold>
38 * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
39 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
40 * @version $Id: MavenEmbedderLoggerManager.java 292888 2005-10-01 01:17:36Z jvanzyl $
42 public class MavenEmbedderLoggerManager
43 extends AbstractLoggerManager
44 implements LoggerManager
, Initializable
47 * Message of this level or higher will be logged.
49 * This field is set by the plexus container thus the name is 'threshold'. The field
50 * currentThreshold contains the current setting of the threshold.
52 private String threshold
= "info";
54 private int currentThreshold
;
56 private Logger logger
;
58 public MavenEmbedderLoggerManager( Logger logger
)
63 public void initialize()
65 debug( "Initializing ConsoleLoggerManager: " + this.hashCode() + "." );
67 currentThreshold
= parseThreshold( threshold
);
69 if ( currentThreshold
== -1 )
71 debug( "Could not parse the threshold level: '" + threshold
+ "', setting to debug." );
72 currentThreshold
= Logger
.LEVEL_DEBUG
;
76 public void setThreshold( int currentThreshold
)
78 this.currentThreshold
= currentThreshold
;
82 * @return Returns the threshold.
84 public int getThreshold()
86 return currentThreshold
;
89 public void setThreshold( String role
, String roleHint
, int threshold
)
93 public int getThreshold( String role
, String roleHint
)
95 return currentThreshold
;
98 public Logger
getLoggerForComponent( String role
, String roleHint
)
103 public void returnComponentLogger( String role
, String roleHint
)
107 public int getActiveLoggerCount()
112 private int parseThreshold( String text
)
114 text
= text
.trim().toLowerCase();
116 if ( text
.equals( "debug" ) )
118 return ConsoleLogger
.LEVEL_DEBUG
;
120 else if ( text
.equals( "info" ) )
122 return ConsoleLogger
.LEVEL_INFO
;
124 else if ( text
.equals( "warn" ) )
126 return ConsoleLogger
.LEVEL_WARN
;
128 else if ( text
.equals( "error" ) )
130 return ConsoleLogger
.LEVEL_ERROR
;
132 else if ( text
.equals( "fatal" ) )
134 return ConsoleLogger
.LEVEL_FATAL
;
141 * Remove this method and all references when this code is verified.
145 private void debug( String msg
)