[Japi-cvs] SF.net SVN: japi: [495] libs/argparser/trunk/src
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2007-07-04 20:06:01
|
Revision: 495 http://svn.sourceforge.net/japi/?rev=495&view=rev Author: christianhujer Date: 2007-07-04 13:05:59 -0700 (Wed, 04 Jul 2007) Log Message: ----------- Added LogCommand. Modified Paths: -------------- libs/argparser/trunk/src/META-INF/services/net.sf.japi.io.args.converter.Converter libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter.properties libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter_de.properties libs/argparser/trunk/src/net/sf/japi/io/args/messages.properties libs/argparser/trunk/src/net/sf/japi/io/args/messages_de.properties Added Paths: ----------- libs/argparser/trunk/src/net/sf/japi/io/args/LogCommand.java libs/argparser/trunk/src/net/sf/japi/io/args/converter/LogLevelConverter.java Modified: libs/argparser/trunk/src/META-INF/services/net.sf.japi.io.args.converter.Converter =================================================================== --- libs/argparser/trunk/src/META-INF/services/net.sf.japi.io.args.converter.Converter 2007-07-04 18:45:20 UTC (rev 494) +++ libs/argparser/trunk/src/META-INF/services/net.sf.japi.io.args.converter.Converter 2007-07-04 20:05:59 UTC (rev 495) @@ -2,3 +2,4 @@ net.sf.japi.io.args.converter.InputStreamConverter net.sf.japi.io.args.converter.IntegerConverter net.sf.japi.io.args.converter.StringConverter +net.sf.japi.io.args.converter.LogLevelConverter Added: libs/argparser/trunk/src/net/sf/japi/io/args/LogCommand.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/LogCommand.java (rev 0) +++ libs/argparser/trunk/src/net/sf/japi/io/args/LogCommand.java 2007-07-04 20:05:59 UTC (rev 495) @@ -0,0 +1,55 @@ +/* + * JAPI libs-argparser is a library for parsing command line arguments. + * Copyright (C) 2007 Christian Hujer. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.sf.japi.io.args; + +import org.jetbrains.annotations.NotNull; +import java.util.logging.Logger; +import java.util.logging.Level; + +/** + * Subclass of BasicCommand that provides logging through {@link java.util.logging}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class LogCommand extends BasicCommand { + + /** The Logger to use. */ + protected final Logger log; + + /** Create a LogCommand with the specified log. + * @param log Logger to use + */ + protected LogCommand(@NotNull final Logger log) { + this.log = log; + } + + /** Create a LogCommand which automatically creates a log that matches the class name. */ + protected LogCommand() { + log = Logger.getLogger(getClass().getName(), getClass().getName()); + } + + /** Sets the log level to log. + * @param level LogLevel to log. + */ + @Option({"l", "level"}) + public void setLevel(@NotNull final Level level) { + log.setLevel(level); + } + +} // class LogCommand Property changes on: libs/argparser/trunk/src/net/sf/japi/io/args/LogCommand.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter.properties =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter.properties 2007-07-04 18:45:20 UTC (rev 494) +++ libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter.properties 2007-07-04 20:05:59 UTC (rev 495) @@ -29,3 +29,5 @@ java.lang.Integer.description=Integer number (decimal, 0... octal, 0x... 0X... #... hexadecimal) java.lang.String.displayName=string java.lang.String.description=Simple text +java.util.logging.Level.displayName=level +java.util.logging.Level.description=Log Level Modified: libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter_de.properties =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter_de.properties 2007-07-04 18:45:20 UTC (rev 494) +++ libs/argparser/trunk/src/net/sf/japi/io/args/converter/Converter_de.properties 2007-07-04 20:05:59 UTC (rev 495) @@ -29,3 +29,5 @@ java.lang.Integer.description=Ganzzahl (dezimal, 0... oktal, 0x... 0X... #... hexadezimal) java.lang.String.displayName=string java.lang.String.description=Einfacher Text. +java.util.logging.Level.displayName=level +java.util.logging.Level.description=Log Level Added: libs/argparser/trunk/src/net/sf/japi/io/args/converter/LogLevelConverter.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/converter/LogLevelConverter.java (rev 0) +++ libs/argparser/trunk/src/net/sf/japi/io/args/converter/LogLevelConverter.java 2007-07-04 20:05:59 UTC (rev 495) @@ -0,0 +1,43 @@ +/* + * JAPI libs-argparser is a library for parsing command line arguments. + * Copyright (C) 2007 Christian Hujer. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.sf.japi.io.args.converter; + +import java.util.logging.Level; +import java.util.Locale; +import org.jetbrains.annotations.NotNull; + +/** + * Created by IntelliJ IDEA. + * + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class LogLevelConverter extends AbstractConverter<Level> { + + /** Create a LogLevelConverter. */ + public LogLevelConverter() { + super(Level.class); + } + + /** {@inheritDoc} */ + @NotNull public Level convert(@NotNull final Locale locale, @NotNull final String arg) throws Exception { + return Level.parse(arg); + } + +} // class LogLevelConverter Property changes on: libs/argparser/trunk/src/net/sf/japi/io/args/converter/LogLevelConverter.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: libs/argparser/trunk/src/net/sf/japi/io/args/messages.properties =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/messages.properties 2007-07-04 18:45:20 UTC (rev 494) +++ libs/argparser/trunk/src/net/sf/japi/io/args/messages.properties 2007-07-04 20:05:59 UTC (rev 495) @@ -28,3 +28,4 @@ setNotExiting=Don't quit Java VM (default). helpHeader= helpFooter= +setLevel=Sets the log level. Modified: libs/argparser/trunk/src/net/sf/japi/io/args/messages_de.properties =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/messages_de.properties 2007-07-04 18:45:20 UTC (rev 494) +++ libs/argparser/trunk/src/net/sf/japi/io/args/messages_de.properties 2007-07-04 20:05:59 UTC (rev 495) @@ -28,3 +28,4 @@ setNotExiting=Java VM nicht beenden (Voreinstellung). helpHeader= helpFooter= +setLevel=Legt den Log-Level fest. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |