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