01: /*
02: * Copyright 2006 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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[] getDefaultArgs() {
28: return new String[] { getTag(), "INFO" };
29: }
30:
31: public String getPurpose() {
32: return "The level of logging detail: ERROR, WARN, INFO, TRACE, DEBUG, SPAM, or ALL";
33: }
34:
35: public String getTag() {
36: return "-logLevel";
37: }
38:
39: public String[] getTagArgs() {
40: return new String[] { "level" };
41: }
42:
43: public int handle(String[] args, int startIndex) {
44: if (startIndex + 1 < args.length) {
45: TreeLogger.Type level = TreeLogger.Type
46: .valueOf(args[startIndex + 1]);
47: if (level != null) {
48: setLogLevel(level);
49: return 1;
50: }
51: }
52:
53: System.err.println(getTag() + " should be followed by one of");
54: System.err
55: .println(" ERROR, WARN, INFO, TRACE, DEBUG, SPAM, or ALL");
56: return -1;
57: }
58:
59: public abstract void setLogLevel(Type level);
60:
61: }
|