]>
Commit | Line | Data |
---|---|---|
652f4bd8 | 1 | /*++\r |
2 | \r | |
c8df018e | 3 | Copyright (c) 2006, Intel Corporation\r |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
652f4bd8 | 8 | \r |
c8df018e | 9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
652f4bd8 | 11 | \r |
c8df018e | 12 | Module Name:\r |
13 | EdkLogger.java\r | |
652f4bd8 | 14 | \r |
c8df018e | 15 | Abstract:\r |
652f4bd8 | 16 | \r |
c8df018e | 17 | --*/\r |
ff225cbb | 18 | package org.tianocore.common.logger;\r |
652f4bd8 | 19 | \r |
c8df018e | 20 | import java.io.File;\r |
652f4bd8 | 21 | \r |
22 | public class EdkLog {\r | |
c8df018e | 23 | public static final String always = "ALWAYS";\r |
24 | \r | |
25 | public static final String error = "ERROR";\r | |
26 | \r | |
27 | public static final String warning = "WARNING";\r | |
28 | \r | |
29 | public static final String info = "INFO";\r | |
30 | \r | |
31 | public static final String verbose = "VERBOSE";\r | |
32 | \r | |
33 | public static final String debug = "DEBUG";\r | |
34 | \r | |
35 | public static final int EDK_ALWAYS = -1;\r | |
36 | \r | |
37 | public static final int EDK_ERROR = 0;\r | |
ff225cbb | 38 | \r |
652f4bd8 | 39 | public static final int EDK_WARNING = 1;\r |
c8df018e | 40 | \r |
41 | public static final int EDK_INFO = 2;\r | |
42 | \r | |
652f4bd8 | 43 | public static final int EDK_VERBOSE = 3;\r |
c8df018e | 44 | \r |
45 | public static final int EDK_DEBUG = 4;\r | |
652f4bd8 | 46 | \r |
47 | private static int logLevel = EDK_INFO;\r | |
c8df018e | 48 | \r |
652f4bd8 | 49 | private static LogMethod logger = new DefaultLogger();\r |
50 | \r | |
51 | public static void log(int level, String message) {\r | |
c8df018e | 52 | if (level <= logLevel) {\r |
53 | logger.putMessage(null, level, message);\r | |
652f4bd8 | 54 | }\r |
652f4bd8 | 55 | }\r |
56 | \r | |
c8df018e | 57 | public static void log(String message) {\r |
58 | if (EDK_INFO <= logLevel) {\r | |
59 | logger.putMessage(null, EDK_INFO, message);\r | |
60 | }\r | |
652f4bd8 | 61 | }\r |
91f7d582 | 62 | \r |
63 | public static void log(Object o, int level, String message) {\r | |
64 | if (level <= logLevel) {\r | |
65 | logger.putMessage(o, level, message);\r | |
66 | }\r | |
67 | }\r | |
68 | \r | |
69 | public static void log(Object o, String message) {\r | |
70 | if (EDK_INFO <= logLevel) {\r | |
71 | logger.putMessage(o, EDK_INFO, message);\r | |
72 | }\r | |
73 | }\r | |
652f4bd8 | 74 | \r |
c8df018e | 75 | public static void flushLogToFile(File file) {\r |
76 | logger.flushToFile(file);\r | |
652f4bd8 | 77 | }\r |
78 | \r | |
79 | public static void setLogger(LogMethod l) {\r | |
80 | logger = l;\r | |
81 | }\r | |
ff225cbb | 82 | \r |
c8df018e | 83 | public static void setLogLevel(int level) {\r |
652f4bd8 | 84 | logLevel = level;\r |
85 | }\r | |
c8df018e | 86 | \r |
87 | public static void setLogLevel(String level) {\r | |
88 | if (level == null) {\r | |
89 | return;\r | |
90 | }\r | |
91 | String levelStr = level.trim();\r | |
92 | if (levelStr.equalsIgnoreCase(error)) {\r | |
93 | logLevel = EDK_ERROR;\r | |
94 | }\r | |
95 | if (levelStr.equalsIgnoreCase(debug)) {\r | |
96 | logLevel = EDK_DEBUG;\r | |
97 | }\r | |
98 | if (levelStr.equalsIgnoreCase(info)) {\r | |
99 | logLevel = EDK_INFO;\r | |
100 | }\r | |
101 | if (levelStr.equalsIgnoreCase(verbose)) {\r | |
102 | logLevel = EDK_VERBOSE;\r | |
103 | }\r | |
104 | if (levelStr.equalsIgnoreCase(warning)) {\r | |
105 | logLevel = EDK_WARNING;\r | |
106 | }\r | |
652f4bd8 | 107 | }\r |
c8df018e | 108 | \r |
109 | public static int getLogLevel() {\r | |
652f4bd8 | 110 | return logLevel;\r |
111 | }\r | |
112 | }\r |