KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > dev > util > arg > ArgHandlerLogLevel


1 /*
2  * Copyright 2006 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package com.google.gwt.dev.util.arg;
17
18 import com.google.gwt.core.ext.TreeLogger;
19 import com.google.gwt.core.ext.TreeLogger.Type;
20 import com.google.gwt.util.tools.ArgHandler;
21
22 /**
23  * Arugment handler for processing the log level flag.
24  */

25 public abstract class ArgHandlerLogLevel extends ArgHandler {
26
27   public String JavaDoc[] getDefaultArgs() {
28     return new String JavaDoc[]{getTag(), "INFO"};
29   }
30
31   public String JavaDoc getPurpose() {
32     return "The level of logging detail: ERROR, WARN, INFO, TRACE, DEBUG, SPAM, or ALL";
33   }
34
35   public String JavaDoc getTag() {
36     return "-logLevel";
37   }
38
39   public String JavaDoc[] getTagArgs() {
40     return new String JavaDoc[]{"level"};
41   }
42
43   public int handle(String JavaDoc[] args, int startIndex) {
44     if (startIndex + 1 < args.length) {
45       TreeLogger.Type level = TreeLogger.Type.valueOf(args[startIndex + 1]);
46       if (level != null) {
47         setLogLevel(level);
48         return 1;
49       }
50     }
51
52     System.err.println(getTag() + " should be followed by one of");
53     System.err.println(" ERROR, WARN, INFO, TRACE, DEBUG, SPAM, or ALL");
54     return -1;
55   }
56
57   public abstract void setLogLevel(Type level);
58
59 }
60
Popular Tags