Skip to content

Commit 8446a5b

Browse files
committed
Refactor LogInfo in JavaSE Lib
1 parent df7badc commit 8446a5b

7 files changed

Lines changed: 37 additions & 39 deletions

File tree

base/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public boolean getIsConnected() {
153153

154154

155155
public void shutdown(String info){
156-
DebugTool.logInfo("Shutdown - " + info);
156+
DebugTool.logInfo(TAG, "Shutdown - " + info);
157157
this.sessionListener.onTransportDisconnected(info);
158158

159159
}
@@ -261,7 +261,7 @@ public void onHeartbeatTimedOut(byte sessionID) {
261261
public void onProtocolSessionStarted(SessionType sessionType,
262262
byte sessionID, byte version, String correlationID, int hashID, boolean isEncrypted) {
263263

264-
DebugTool.logInfo("Protocol session started");
264+
DebugTool.logInfo(TAG, "Protocol session started");
265265

266266
this.sessionId = sessionID;
267267
if (sessionType.eq(SessionType.RPC)){
@@ -397,7 +397,7 @@ private VideoStreamingProtocol getAcceptedProtocol() {
397397
*************************************************************************************************************************************************************************/
398398

399399
public void onProtocolMessageBytesToSend(SdlPacket packet) {
400-
//DebugTool.logInfo("onProtocolMessageBytesToSend - " + packet.getTransportType());
400+
//DebugTool.logInfo(TAG, "onProtocolMessageBytesToSend - " + packet.getTransportType());
401401
sdlProtocol.sendPacket(packet);
402402
}
403403

base/src/main/java/com/smartdevicelink/transport/TransportManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ public void onError() {
189189
@Override
190190
public void onConnectionTerminated(String reason) {
191191
if(record != null){
192-
DebugTool.logInfo("Transport disconnected - " + record);
192+
DebugTool.logInfo(TAG, "Transport disconnected - " + record);
193193
}else{
194-
DebugTool.logInfo("Transport disconnected");
194+
DebugTool.logInfo(TAG, "Transport disconnected");
195195

196196
}
197197

base/src/main/java/com/smartdevicelink/transport/WebSocketServer.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void stop(){
8787

8888
@Override
8989
public void write(SdlPacket packet){
90-
//DebugTool.logInfo("Atttempt to write packet " + packet);
90+
//DebugTool.logInfo(TAG, "Atttempt to write packet " + packet);
9191
if(packet != null
9292
&& this.webSocket != null
9393
&& this.webSocket.isOpen()) {
@@ -103,7 +103,7 @@ public void setCallback(TransportCallback callback) {
103103

104104
@Override
105105
public void onOpen(WebSocket webSocket, ClientHandshake clientHandshake) {
106-
DebugTool.logInfo("onOpen");
106+
DebugTool.logInfo(TAG, "onOpen");
107107
this.webSocket = webSocket;
108108

109109
if(callback!=null){
@@ -113,11 +113,11 @@ public void onOpen(WebSocket webSocket, ClientHandshake clientHandshake) {
113113

114114
@Override
115115
public void onClose(WebSocket webSocket, int i, String s, boolean b) {
116-
DebugTool.logInfo("onClose");
116+
DebugTool.logInfo(TAG, "onClose");
117117
try{
118-
DebugTool.logInfo("Closing id - " + i);
119-
DebugTool.logInfo("Closing string - " + s);
120-
DebugTool.logInfo("Closing from remote? " + b);
118+
DebugTool.logInfo(TAG, "Closing id - " + i);
119+
DebugTool.logInfo(TAG, "Closing string - " + s);
120+
DebugTool.logInfo(TAG, "Closing from remote? " + b);
121121
}catch (Exception e){
122122
e.printStackTrace();
123123
}
@@ -132,7 +132,7 @@ public void onClose(WebSocket webSocket, int i, String s, boolean b) {
132132
public void onWebsocketCloseInitiated(WebSocket conn, int code, String reason) {
133133
super.onWebsocketCloseInitiated(conn, code, reason);
134134
try{
135-
DebugTool.logInfo("Code - " + code + " Reason - " + reason);
135+
DebugTool.logInfo(TAG, "Code - " + code + " Reason - " + reason);
136136
}catch (Exception e){}
137137
}
138138

@@ -144,7 +144,7 @@ public void onMessage(WebSocket webSocket, String s) {
144144
@Override
145145
public void onMessage(WebSocket conn, ByteBuffer message) {
146146
super.onMessage(conn, message);
147-
//DebugTool.logInfo("on Message - ByteBuffer");
147+
//DebugTool.logInfo(TAG, "on Message - ByteBuffer");
148148
byte input;
149149

150150
if(message != null){
@@ -163,7 +163,7 @@ public void onMessage(WebSocket conn, ByteBuffer message) {
163163
synchronized (WebSocketServer.this) {
164164
SdlPacket packet = psm.getFormedPacket();
165165
if (callback != null && packet != null) {
166-
/// DebugTool.logInfo("Read a packet: " + packet);
166+
/// DebugTool.logInfo(TAG, "Read a packet: " + packet);
167167
packet.setTransportRecord(transportRecord);
168168
callback.onPacketReceived(packet);
169169
}
@@ -190,7 +190,7 @@ public void onError(WebSocket webSocket, Exception e) {
190190

191191
@Override
192192
public void onStart() {
193-
DebugTool.logInfo("onStart");
193+
DebugTool.logInfo(TAG, "onStart");
194194
psm = new SdlPsm();
195195

196196
}

hello_sdl_java/src/main/java/com/smartdevicelink/java/Main.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public static void main(String[] args) {
5454
}
5555
System.gc();
5656
Thread.sleep(500);
57-
DebugTool.logInfo( "Attempting to start SDL Service again");
57+
DebugTool.logInfo(null, "Attempting to start SDL Service again");
5858
startSdlService();
59-
DebugTool.logInfo("SdlService started");
59+
DebugTool.logInfo(null, "SdlService started");
6060

6161
} catch (InterruptedException e) {
6262
e.printStackTrace();
@@ -85,7 +85,7 @@ private static void startSdlService() {
8585

8686
@Override
8787
public void run() {
88-
DebugTool.logInfo("Starting SDL Service");
88+
DebugTool.logInfo(null, "Starting SDL Service");
8989
sdlService = new SdlService(new WebSocketServerConfig(5432, -1), serviceCallback);
9090
sdlService.start();
9191

hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
package com.smartdevicelink.java;
3434

35-
import android.util.Log;
3635
import com.smartdevicelink.managers.CompletionListener;
3736
import com.smartdevicelink.managers.SdlManager;
3837
import com.smartdevicelink.managers.SdlManagerListener;
@@ -91,7 +90,7 @@ public SdlService(BaseTransportConfig config, SdlServiceCallback callback){
9190
}
9291

9392
public void start() {
94-
DebugTool.logInfo("SdlService start() ");
93+
DebugTool.logInfo(TAG, "SdlService start() ");
9594
if(sdlManager != null){
9695
sdlManager.start();
9796
}
@@ -109,7 +108,7 @@ private void buildSdlManager(BaseTransportConfig transport) {
109108
// Build flavors are selected by the "build variants" tab typically located in the bottom left of Android Studio
110109
// Typically in your app, you will only set one of these.
111110
if (sdlManager == null) {
112-
DebugTool.logInfo("Creating SDL Manager");
111+
DebugTool.logInfo(TAG, "Creating SDL Manager");
113112

114113
//FIXME add the transport type
115114
// The app type to be used
@@ -121,12 +120,12 @@ private void buildSdlManager(BaseTransportConfig transport) {
121120
SdlManagerListener listener = new SdlManagerListener() {
122121
@Override
123122
public void onStart(SdlManager sdlManager) {
124-
DebugTool.logInfo("SdlManager onStart");
123+
DebugTool.logInfo(TAG, "SdlManager onStart");
125124
}
126125

127126
@Override
128127
public void onDestroy(SdlManager sdlManager) {
129-
DebugTool.logInfo("SdlManager onDestroy ");
128+
DebugTool.logInfo(TAG, "SdlManager onDestroy ");
130129
SdlService.this.sdlManager = null;
131130
if(SdlService.this.callback != null){
132131
SdlService.this.callback.onEnd();
@@ -220,14 +219,14 @@ private void setVoiceCommands(){
220219
VoiceCommand voiceCommand1 = new VoiceCommand(list1, new VoiceCommandSelectionListener() {
221220
@Override
222221
public void onVoiceCommandSelected() {
223-
Log.i(TAG, "Voice Command 1 triggered");
222+
DebugTool.logInfo(TAG, "Voice Command 1 triggered");
224223
}
225224
});
226225

227226
VoiceCommand voiceCommand2 = new VoiceCommand(list2, new VoiceCommandSelectionListener() {
228227
@Override
229228
public void onVoiceCommandSelected() {
230-
Log.i(TAG, "Voice Command 2 triggered");
229+
DebugTool.logInfo(TAG, "Voice Command 2 triggered");
231230
}
232231
});
233232

@@ -248,15 +247,15 @@ private void sendMenus(){
248247
MenuCell mainCell1 = new MenuCell("Test Cell 1 (speak)", livio, null, new MenuSelectionListener() {
249248
@Override
250249
public void onTriggered(TriggerSource trigger) {
251-
Log.i(TAG, "Test cell 1 triggered. Source: "+ trigger.toString());
250+
DebugTool.logInfo(TAG, "Test cell 1 triggered. Source: "+ trigger.toString());
252251
showTest();
253252
}
254253
});
255254

256255
MenuCell mainCell2 = new MenuCell("Test Cell 2", null, voice2, new MenuSelectionListener() {
257256
@Override
258257
public void onTriggered(TriggerSource trigger) {
259-
Log.i(TAG, "Test cell 2 triggered. Source: "+ trigger.toString());
258+
DebugTool.logInfo(TAG, "Test cell 2 triggered. Source: "+ trigger.toString());
260259
}
261260
});
262261

@@ -265,14 +264,14 @@ public void onTriggered(TriggerSource trigger) {
265264
MenuCell subCell1 = new MenuCell("SubCell 1",null, null, new MenuSelectionListener() {
266265
@Override
267266
public void onTriggered(TriggerSource trigger) {
268-
Log.i(TAG, "Sub cell 1 triggered. Source: "+ trigger.toString());
267+
DebugTool.logInfo(TAG, "Sub cell 1 triggered. Source: "+ trigger.toString());
269268
}
270269
});
271270

272271
MenuCell subCell2 = new MenuCell("SubCell 2",null, null, new MenuSelectionListener() {
273272
@Override
274273
public void onTriggered(TriggerSource trigger) {
275-
Log.i(TAG, "Sub cell 2 triggered. Source: "+ trigger.toString());
274+
DebugTool.logInfo(TAG, "Sub cell 2 triggered. Source: "+ trigger.toString());
276275
}
277276
});
278277

@@ -289,7 +288,7 @@ public void onTriggered(TriggerSource trigger) {
289288
MenuCell mainCell5 = new MenuCell("Clear the menu",null, null, new MenuSelectionListener() {
290289
@Override
291290
public void onTriggered(TriggerSource trigger) {
292-
Log.i(TAG, "Clearing Menu. Source: "+ trigger.toString());
291+
DebugTool.logInfo(TAG, "Clearing Menu. Source: "+ trigger.toString());
293292
// Clear this thing
294293
sdlManager.getScreenManager().setMenu(Collections.<MenuCell>emptyList());
295294
showAlert("Menu Cleared");
@@ -321,7 +320,7 @@ private void performWelcomeShow() {
321320
@Override
322321
public void onComplete(boolean success) {
323322
if (success){
324-
Log.i(TAG, "welcome show successful");
323+
DebugTool.logInfo(TAG, "welcome show successful");
325324
}
326325
}
327326
});
@@ -370,7 +369,7 @@ public void onChoiceSelected(ChoiceCell choiceCell, TriggerSource triggerSource,
370369

371370
@Override
372371
public void onError(String error) {
373-
Log.e(TAG, "There was an error showing the perform interaction: "+ error);
372+
DebugTool.logError(TAG, "There was an error showing the perform interaction: "+ error);
374373
}
375374
});
376375
sdlManager.getScreenManager().presentChoiceSet(choiceSet, InteractionMode.MANUAL_ONLY);

javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void run() {
6868
}
6969
});
7070

71-
DebugTool.logInfo("start");
71+
DebugTool.logInfo(TAG, "start");
7272
if (lifecycleManager == null) {
7373
if (transport != null && (transport.getTransportType().equals(TransportType.WEB_SOCKET_SERVER) || transport.getTransportType().equals(TransportType.CUSTOM))) {
7474
super.start();
@@ -96,7 +96,7 @@ protected void initialize() {
9696
void checkState() {
9797
if (permissionManager != null && fileManager != null && screenManager != null) {
9898
if (permissionManager.getState() == BaseSubManager.READY && fileManager.getState() == BaseSubManager.READY && screenManager.getState() == BaseSubManager.READY) {
99-
DebugTool.logInfo("Starting sdl manager, all sub managers are in ready state");
99+
DebugTool.logInfo(TAG, "Starting sdl manager, all sub managers are in ready state");
100100
transitionToState(BaseSubManager.READY);
101101
handleQueuedNotifications();
102102
notifyDevListener(null);
@@ -107,7 +107,7 @@ void checkState() {
107107
transitionToState(BaseSubManager.ERROR);
108108
notifyDevListener(info);
109109
} else if (permissionManager.getState() == BaseSubManager.SETTING_UP || fileManager.getState() == BaseSubManager.SETTING_UP || screenManager.getState() == BaseSubManager.SETTING_UP) {
110-
DebugTool.logInfo("SETTING UP sdl manager, some sub managers are still setting up");
110+
DebugTool.logInfo(TAG, "SETTING UP sdl manager, some sub managers are still setting up");
111111
transitionToState(BaseSubManager.SETTING_UP);
112112
// No need to notify developer here!
113113
} else {

javaSE/src/main/java/com/smartdevicelink/util/HttpRequestTask.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.smartdevicelink.util;
22

33
import android.os.AsyncTask;
4-
import android.util.Log;
54

65
import java.io.BufferedReader;
76
import java.io.BufferedWriter;
@@ -69,7 +68,7 @@ protected String doInBackground(String... params) {
6968
}
7069

7170
if(urlString == null || request_type == null){
72-
Log.e(TAG, "Can't process request, param error");
71+
DebugTool.logError(TAG, "Can't process request, param error");
7372
if(cb!=null){
7473
cb.httpFailure(-1);
7574
cb = null;
@@ -133,7 +132,7 @@ protected String doInBackground(String... params) {
133132
cb.httpFailure(responseCode);
134133
cb = null;
135134
}
136-
Log.e(TAG, "Failed to download file - " + responseCode);
135+
DebugTool.logError(TAG, "Failed to download file - " + responseCode);
137136
return null;
138137
}
139138

@@ -152,7 +151,7 @@ protected String doInBackground(String... params) {
152151
try {
153152
reader.close();
154153
} catch (final IOException e) {
155-
Log.e(TAG, "Error closing stream", e);
154+
DebugTool.logError(TAG, "Error closing stream", e);
156155
}
157156
}
158157
if(cb!=null){

0 commit comments

Comments
 (0)