1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sourceforge.jarduino.util;
18
19
20
21
22 public class ArduinoLogger {
23
24
25
26 private final ArduinoLogManager theManager;
27
28
29
30
31 private final Class<?> theOwner;
32
33
34
35
36
37
38 public ArduinoLogger(final ArduinoLogManager pManager,
39 final Class<?> pOwner) {
40 theManager = pManager;
41 theOwner = pOwner;
42 }
43
44
45
46
47
48
49 public void debug(final String pFormat,
50 final Object... pArgs) {
51 final String myMessage = String.format(pFormat, pArgs);
52 final String myLogMessage = theManager.formatMessage(theOwner, ArduinoLogLevel.DEBUG, myMessage);
53 theManager.writeLogMessage(myLogMessage);
54 }
55
56
57
58
59
60
61 public void debug(final String pMessage,
62 final byte[] pData) {
63 final String myLogMessage = theManager.formatMessage(theOwner, ArduinoLogLevel.DEBUG, pMessage);
64 final String myLogData = ArduinoLogManager.formatData(pData);
65 theManager.writeLogMessage(myLogMessage + myLogData);
66 }
67
68
69
70
71
72
73
74
75 public void debug(final String pMessage,
76 final byte[] pData,
77 final int pOffset,
78 final int pLength) {
79 final String myLogMessage = theManager.formatMessage(theOwner, ArduinoLogLevel.DEBUG, pMessage);
80 final String myLogData = ArduinoLogManager.formatData(pData, pOffset, pLength);
81 theManager.writeLogMessage(myLogMessage + myLogData);
82 }
83
84
85
86
87
88 public void info(final String pFormat,
89 final Object... pArgs) {
90 final String myMessage = String.format(pFormat, pArgs);
91 final String myLogMessage = theManager.formatMessage(theOwner, ArduinoLogLevel.INFO, myMessage);
92 theManager.writeLogMessage(myLogMessage);
93 }
94
95
96
97
98
99
100 public void error(final String pFormat,
101 final Object... pArgs) {
102 final String myMessage = String.format(pFormat, pArgs);
103 final String myLogMessage = theManager.formatMessage(theOwner, ArduinoLogLevel.ERROR, myMessage);
104 theManager.writeLogMessage(myLogMessage);
105 }
106
107
108
109
110
111
112 public void error(final String pMessage,
113 final Throwable pException) {
114 final String myLogMessage = theManager.formatMessage(theOwner, ArduinoLogLevel.ERROR, pMessage);
115 theManager.writeLogMessage(myLogMessage, pException);
116 }
117
118
119
120
121
122
123 public void fatal(final String pFormat,
124 final Object... pArgs) {
125 final String myMessage = String.format(pFormat, pArgs);
126 final String myLogMessage = theManager.formatMessage(theOwner, ArduinoLogLevel.FATAL, myMessage);
127 theManager.writeLogMessage(myLogMessage);
128 }
129
130
131
132
133
134
135 public void fatal(final String pMessage,
136 final Throwable pException) {
137 final String myLogMessage = theManager.formatMessage(theOwner, ArduinoLogLevel.FATAL, pMessage);
138 theManager.writeLogMessage(myLogMessage, pException);
139 }
140 }