|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
AstyleLog.java | - | 0% | 0% | 0% |
|
1 | package net.sourceforge.astyleclipse; | |
2 | ||
3 | import org.eclipse.core.runtime.IStatus; | |
4 | import org.eclipse.core.runtime.Status; | |
5 | ||
6 | /** | |
7 | * The logger of convenience for the Favorites plug-in. | |
8 | */ | |
9 | public class AstyleLog { | |
10 | /** | |
11 | * Log the specified information. | |
12 | * | |
13 | * @param message, a human-readable message, localized to the | |
14 | * current locale. | |
15 | */ | |
16 | 0 | public static void logInfo(String message) { |
17 | 0 | log(IStatus.INFO, IStatus.OK, message, null); |
18 | } | |
19 | ||
20 | /** | |
21 | * Log the specified error. | |
22 | * | |
23 | * @param exception, a low-level exception. | |
24 | */ | |
25 | 0 | public static void logError(Throwable exception) { |
26 | 0 | logError("Unexpected Exception", exception); |
27 | } | |
28 | ||
29 | /** | |
30 | * Log the specified error. | |
31 | * | |
32 | * @param message, a human-readable message, localized to the | |
33 | * current locale. | |
34 | * @param exception, a low-level exception, or <code>null</code> | |
35 | * if not applicable. | |
36 | */ | |
37 | 0 | public static void logError(String message, Throwable exception) { |
38 | 0 | log(IStatus.ERROR, IStatus.OK, message, exception); |
39 | } | |
40 | ||
41 | /** | |
42 | * Log the specified information. | |
43 | * | |
44 | * @param severity, the severity; one of the following: | |
45 | * <code>IStatus.OK</code>, | |
46 | * <code>IStatus.ERROR</code>, | |
47 | * <code>IStatus.INFO</code>, or | |
48 | * <code>IStatus.WARNING</code>. | |
49 | * @param pluginId. the unique identifier of the relevant | |
50 | * plug-in. | |
51 | * @param code, the plug-in-specific status code, or | |
52 | * <code>OK</code>. | |
53 | * @param message, a human-readable message, localized to the | |
54 | * current locale. | |
55 | * @param exception, a low-level exception, or <code>null</code> | |
56 | * if not applicable. | |
57 | */ | |
58 | 0 | public static void log(int severity, int code, String message, |
59 | Throwable exception) { | |
60 | ||
61 | 0 | log(createStatus(severity, code, message, exception)); |
62 | } | |
63 | ||
64 | /** | |
65 | * Create a status object representing the specified information. | |
66 | * | |
67 | * @param severity, the severity; one of the following: | |
68 | * <code>IStatus.OK</code>, | |
69 | * <code>IStatus.ERROR</code>, | |
70 | * <code>IStatus.INFO</code>, or | |
71 | * <code>IStatus.WARNING</code>. | |
72 | * @param pluginId, the unique identifier of the relevant | |
73 | * plug-in. | |
74 | * @param code, the plug-in-specific status code, or | |
75 | * <code>OK</code>. | |
76 | * @param message, a human-readable message, localized to the | |
77 | * current locale. | |
78 | * @param exception, a low-level exception, or <code>null</code> | |
79 | * if not applicable. | |
80 | * @return, the status object (not <code>null</code>). | |
81 | */ | |
82 | 0 | public static IStatus createStatus(int severity, int code, |
83 | String message, Throwable exception) { | |
84 | ||
85 | 0 | return new Status(severity, Activator.PLUGIN_ID, code, |
86 | message, exception); | |
87 | } | |
88 | ||
89 | /** | |
90 | * Log the given status. | |
91 | * | |
92 | * @param status, the status to log. | |
93 | */ | |
94 | 0 | public static void log(IStatus status) { |
95 | 0 | Activator.getDefault().getLog().log(status); |
96 | } | |
97 | } |
|