Skip to content

Commit e6e55f1

Browse files
Merge pull request #1378 from smartdevicelink/bugfix/issue_1377_logging
Create Log Wrapper and Replace Base library logging
2 parents 7a2f581 + d43a949 commit e6e55f1

File tree

98 files changed

+1336
-1280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1336
-1280
lines changed

android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
import android.content.Context;
44
import android.content.Intent;
55
import android.os.Build;
6-
import android.util.Log;
76

87
import com.smartdevicelink.transport.SdlBroadcastReceiver;
98
import com.smartdevicelink.transport.SdlRouterService;
9+
import com.smartdevicelink.util.DebugTool;
1010

1111
public class SdlReceiver extends SdlBroadcastReceiver {
1212
private static final String TAG = "SdlBroadcastReciever";
1313

1414
@Override
1515
public void onSdlEnabled(Context context, Intent intent) {
16-
Log.d(TAG, "SDL Enabled");
16+
DebugTool.logInfo(TAG, "SDL Enabled");
1717
intent.setClass(context, SdlService.class);
1818

1919
// SdlService needs to be foregrounded in Android O and above

android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
1-
/*
2-
* Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
3-
* All rights reserved.
4-
*
5-
* Redistribution and use in source and binary forms, with or without
6-
* modification, are permitted provided that the following conditions are met:
7-
*
8-
* Redistributions of source code must retain the above copyright notice, this
9-
* list of conditions and the following disclaimer.
10-
*
11-
* Redistributions in binary form must reproduce the above copyright notice,
12-
* this list of conditions and the following
13-
* disclaimer in the documentation and/or other materials provided with the
14-
* distribution.
15-
*
16-
* Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
17-
* contributors may be used to endorse or promote products derived from this
18-
* software without specific prior written permission.
19-
*
20-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23-
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24-
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26-
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30-
* POSSIBILITY OF SUCH DAMAGE.
31-
*/
1+
/*
2+
* Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* Redistributions of source code must retain the above copyright notice, this
9+
* list of conditions and the following disclaimer.
10+
*
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following
13+
* disclaimer in the documentation and/or other materials provided with the
14+
* distribution.
15+
*
16+
* Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
17+
* contributors may be used to endorse or promote products derived from this
18+
* software without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30+
* POSSIBILITY OF SUCH DAMAGE.
31+
*/
3232
package com.smartdevicelink.SdlConnection;
3333

3434

3535
import android.content.ComponentName;
36-
import android.util.Log;
3736

3837
import com.smartdevicelink.exception.SdlException;
3938
import com.smartdevicelink.protocol.AbstractProtocol;
@@ -56,6 +55,7 @@
5655
import com.smartdevicelink.transport.USBTransport;
5756
import com.smartdevicelink.transport.USBTransportConfig;
5857
import com.smartdevicelink.transport.enums.TransportType;
58+
import com.smartdevicelink.util.DebugTool;
5959

6060
import java.util.List;
6161
import java.util.concurrent.CopyOnWriteArrayList;
@@ -127,10 +127,10 @@ private void constructor(BaseTransportConfig transportConfig,RouterServiceValida
127127
//rsvp = new RouterServiceValidator(((MultiplexTransportConfig)transportConfig).getContext());
128128
//vlad.setFlags(RouterServiceValidator.FLAG_DEBUG_VERSION_CHECK);
129129
if(rsvp.validate()){
130-
Log.w(TAG, "SDL Router service is valid; attempting to connect");
130+
DebugTool.logWarning(TAG, "SDL Router service is valid; attempting to connect");
131131
((MultiplexTransportConfig)transportConfig).setService(rsvp.getService());//Let thes the transport broker know which service to connect to
132132
}else{
133-
Log.w(TAG, "SDL Router service isn't trusted. Enabling legacy bluetooth connection.");
133+
DebugTool.logWarning(TAG, "SDL Router service isn't trusted. Enabling legacy bluetooth connection.");
134134
if(cachedMultiConfig == null){
135135
cachedMultiConfig = (MultiplexTransportConfig) transportConfig;
136136
cachedMultiConfig.setService(null);
@@ -573,7 +573,7 @@ public void onResetIncomingHeartbeat(SessionType sessionType, byte sessionID){
573573

574574
public void forceHardwareConnectEvent(TransportType type){
575575
if(_transport == null){
576-
Log.w(TAG, "Unable to force connect, transport was null!");
576+
DebugTool.logWarning(TAG, "Unable to force connect, transport was null!");
577577
return;
578578
}
579579
if(isLegacyModeEnabled()){//We know we should no longer be in legacy mode for future connections, so lets clear out that flag
@@ -594,7 +594,7 @@ public void forceHardwareConnectEvent(TransportType type){
594594
}
595595
}else if(tempCompName!=null){
596596
//We have a conflicting service request
597-
Log.w(TAG, "Conflicting services. Disconnecting from current and connecting to new");
597+
DebugTool.logWarning(TAG, "Conflicting services. Disconnecting from current and connecting to new");
598598
//Log.w(TAG, "Old service " + config.getService().toShortString());
599599
//Log.w(TAG, "New Serivce " + tempCompName.toString());
600600
multi.disconnect();
@@ -626,9 +626,9 @@ public void forceHardwareConnectEvent(TransportType type){
626626
//_transport.disconnect();
627627
return;
628628
}
629-
Log.w(TAG, "Using own transport, but not connected. Attempting to join multiplexing");
629+
DebugTool.logWarning(TAG, "Using own transport, but not connected. Attempting to join multiplexing");
630630
}else{
631-
Log.w(TAG, "Currently in legacy mode connected to own transport service. Nothing will take place on trnasport cycle");
631+
DebugTool.logWarning(TAG, "Currently in legacy mode connected to own transport service. Nothing will take place on trnasport cycle");
632632
}
633633
}
634634

android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
import android.annotation.SuppressLint;
3535
import android.os.Build;
36-
import android.util.Log;
3736
import android.view.Surface;
3837

3938
import com.smartdevicelink.encoder.SdlEncoder;
@@ -61,6 +60,7 @@
6160
import com.smartdevicelink.transport.BaseTransportConfig;
6261
import com.smartdevicelink.transport.MultiplexTransport;
6362
import com.smartdevicelink.transport.enums.TransportType;
63+
import com.smartdevicelink.util.DebugTool;
6464
import com.smartdevicelink.util.Version;
6565

6666
import java.io.IOException;
@@ -264,7 +264,7 @@ public IVideoStreamListener startVideoStream() {
264264
return packetizer;
265265
}
266266
default:
267-
Log.e(TAG, "Protocol " + protocol + " is not supported.");
267+
DebugTool.logError(TAG, "Protocol " + protocol + " is not supported.");
268268
return null;
269269
}
270270
} catch (IOException e) {
@@ -291,7 +291,7 @@ public void startRPCStream(InputStream is, RPCRequest request, SessionType sType
291291
mRPCPacketizer = new StreamRPCPacketizer(null, this, is, request, sType, rpcSessionID, wiproVersion, 0, this);
292292
mRPCPacketizer.start();
293293
} catch (Exception e) {
294-
Log.e(TAG, "Unable to start streaming:" + e.toString());
294+
DebugTool.logError(TAG, "Unable to start streaming:" + e.toString());
295295
}
296296
}
297297

@@ -304,7 +304,7 @@ public OutputStream startRPCStream(RPCRequest request, SessionType sType, byte r
304304
mRPCPacketizer.start();
305305
return os;
306306
} catch (Exception e) {
307-
Log.e(TAG, "Unable to start streaming:" + e.toString());
307+
DebugTool.logError(TAG, "Unable to start streaming:" + e.toString());
308308
}
309309
return null;
310310
}
@@ -638,7 +638,7 @@ public void onProtocolError(String info, Exception e) {
638638

639639
@Override
640640
public void sendHeartbeat(IHeartbeatMonitor monitor) {
641-
Log.d(TAG, "Asked to send heartbeat");
641+
DebugTool.logInfo(TAG, "Asked to send heartbeat");
642642
if (_sdlConnection != null)
643643
_sdlConnection.sendHeartbeat(this);
644644
}

android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession2.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
package com.smartdevicelink.SdlConnection;
3434

3535
import android.content.Context;
36-
import android.util.Log;
3736

3837
import com.smartdevicelink.exception.SdlException;
3938
import com.smartdevicelink.protocol.ISdlProtocol;
@@ -47,6 +46,7 @@
4746
import com.smartdevicelink.transport.MultiplexTransportConfig;
4847
import com.smartdevicelink.transport.TCPTransportConfig;
4948
import com.smartdevicelink.transport.enums.TransportType;
49+
import com.smartdevicelink.util.DebugTool;
5050
import com.smartdevicelink.util.MediaStreamingStatus;
5151
import com.smartdevicelink.util.Version;
5252

@@ -210,7 +210,7 @@ public boolean getIsConnected() {
210210

211211

212212
public void shutdown(String info){
213-
Log.d(TAG, "Shutdown - " + info);
213+
DebugTool.logInfo(TAG, "Shutdown - " + info);
214214
if(mediaStreamingStatus != null) {
215215
mediaStreamingStatus.clear();
216216
}

android/sdl_android/src/main/java/com/smartdevicelink/encoder/EncoderUtils.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
import android.annotation.TargetApi;
3434
import android.media.MediaFormat;
3535
import android.os.Build;
36-
import android.util.Log;
36+
37+
import com.smartdevicelink.util.DebugTool;
3738

3839
import java.nio.ByteBuffer;
3940

@@ -63,7 +64,7 @@ public static byte[] getCodecSpecificData(MediaFormat format) {
6364
if (name.equals("video/avc")) {
6465
return getAVCCodecSpecificData(format);
6566
} else {
66-
Log.w(TAG, "Retrieving codec-specific data for " + name + " is not supported");
67+
DebugTool.logWarning(TAG, "Retrieving codec-specific data for " + name + " is not supported");
6768
return null;
6869
}
6970
}
@@ -81,7 +82,7 @@ private static byte[] getAVCCodecSpecificData(MediaFormat format) {
8182
// For H.264, "csd-0" contains SPS and "csd-1" contains PPS. Refer to the documentation
8283
// of MediaCodec.
8384
if (!(format.containsKey("csd-0") && format.containsKey("csd-1"))) {
84-
Log.w(TAG, "H264 codec specific data not found");
85+
DebugTool.logWarning(TAG, "H264 codec specific data not found");
8586
return null;
8687
}
8788

@@ -96,7 +97,7 @@ private static byte[] getAVCCodecSpecificData(MediaFormat format) {
9697
pps.get(output, spsLen, ppsLen);
9798
} catch (Exception e) {
9899
// should not happen
99-
Log.w(TAG, "Error while copying H264 codec specific data: " + e);
100+
DebugTool.logWarning(TAG, "Error while copying H264 codec specific data: " + e);
100101
return null;
101102
}
102103

android/sdl_android/src/main/java/com/smartdevicelink/encoder/SdlEncoder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
import android.media.MediaCodecInfo;
3737
import android.media.MediaFormat;
3838
import android.os.Build;
39-
import android.util.Log;
4039
import android.view.Surface;
4140

4241
import com.smartdevicelink.proxy.interfaces.IVideoStreamListener;
42+
import com.smartdevicelink.util.DebugTool;
4343

4444
import java.io.IOException;
4545
import java.io.PipedOutputStream;
@@ -198,7 +198,7 @@ public void drainEncoder(boolean endOfStream) {
198198
MediaFormat format = mEncoder.getOutputFormat();
199199
mH264CodecSpecificData = EncoderUtils.getCodecSpecificData(format);
200200
} else {
201-
Log.w(TAG, "Output format change notified more than once, ignoring.");
201+
DebugTool.logWarning(TAG, "Output format change notified more than once, ignoring.");
202202
}
203203
} else if (encoderStatus < 0) {
204204
} else {
@@ -208,7 +208,7 @@ public void drainEncoder(boolean endOfStream) {
208208
if (mH264CodecSpecificData != null) {
209209
mBufferInfo.size = 0;
210210
} else {
211-
Log.i(TAG, "H264 codec specific data not retrieved yet.");
211+
DebugTool.logInfo(TAG, "H264 codec specific data not retrieved yet.");
212212
}
213213
}
214214

android/sdl_android/src/main/java/com/smartdevicelink/encoder/VirtualDisplayEncoder.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import android.media.MediaCodecInfo;
4141
import android.media.MediaFormat;
4242
import android.os.Build;
43-
import android.util.Log;
4443
import android.view.Display;
4544
import android.view.Surface;
4645

@@ -49,6 +48,7 @@
4948
import com.smartdevicelink.proxy.rpc.VideoStreamingFormat;
5049
import com.smartdevicelink.proxy.rpc.enums.VideoStreamingCodec;
5150
import com.smartdevicelink.streaming.video.VideoStreamingParameters;
51+
import com.smartdevicelink.util.DebugTool;
5252

5353
import java.nio.ByteBuffer;
5454

@@ -83,12 +83,12 @@ public class VirtualDisplayEncoder {
8383
*/
8484
public void init(Context context, IVideoStreamListener outputListener, VideoStreamingParameters streamingParams) throws Exception {
8585
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
86-
Log.e(TAG, "API level of 19 required for VirtualDisplayEncoder");
86+
DebugTool.logError(TAG, "API level of 19 required for VirtualDisplayEncoder");
8787
throw new Exception("API level of 19 required");
8888
}
8989

9090
if (context == null || outputListener == null || streamingParams == null || streamingParams.getResolution() == null || streamingParams.getFormat() == null) {
91-
Log.e(TAG, "init parameters cannot be null for VirtualDisplayEncoder");
91+
DebugTool.logError(TAG, "init parameters cannot be null for VirtualDisplayEncoder");
9292
throw new Exception("init parameters cannot be null");
9393
}
9494

@@ -122,7 +122,7 @@ public void setStreamingParams(VideoStreamingParameters streamingParams) {
122122
*/
123123
public void start() throws Exception {
124124
if (!initPassed) {
125-
Log.e(TAG, "VirtualDisplayEncoder was not properly initialized with the init() method.");
125+
DebugTool.logError(TAG, "VirtualDisplayEncoder was not properly initialized with the init() method.");
126126
return;
127127
}
128128
if (streamingParams == null || streamingParams.getResolution() == null || streamingParams.getFormat() == null) {
@@ -142,15 +142,15 @@ public void start() throws Exception {
142142
startEncoder();
143143

144144
} catch (Exception ex) {
145-
Log.e(TAG, "Unable to create Virtual Display.");
145+
DebugTool.logError(TAG, "Unable to create Virtual Display.");
146146
throw new RuntimeException(ex);
147147
}
148148
}
149149
}
150150

151151
public void shutDown() {
152152
if (!initPassed) {
153-
Log.e(TAG, "VirtualDisplayEncoder was not properly initialized with the init() method.");
153+
DebugTool.logError(TAG, "VirtualDisplayEncoder was not properly initialized with the init() method.");
154154
return;
155155
}
156156
try {
@@ -175,7 +175,7 @@ public void shutDown() {
175175
inputSurface = null;
176176
}
177177
} catch (Exception ex) {
178-
Log.e(TAG, "shutDown() failed");
178+
DebugTool.logError(TAG, "shutDown() failed");
179179
}
180180
}
181181

@@ -266,7 +266,7 @@ public void onOutputFormatChanged(MediaCodec codec, MediaFormat format) {
266266
encoderThread = new Thread(new EncoderCompat());
267267

268268
} else {
269-
Log.e(TAG, "Unable to start encoder. Android OS version " + Build.VERSION.SDK_INT + "is not supported");
269+
DebugTool.logError(TAG, "Unable to start encoder. Android OS version " + Build.VERSION.SDK_INT + "is not supported");
270270
}
271271

272272
return surface;
@@ -315,7 +315,7 @@ public void run() {
315315
try {
316316
drainEncoder(false);
317317
} catch (Exception e) {
318-
Log.w(TAG, "Error attempting to drain encoder");
318+
DebugTool.logWarning(TAG, "Error attempting to drain encoder");
319319
} finally {
320320
mVideoEncoder.release();
321321
}
@@ -349,7 +349,7 @@ void drainEncoder(boolean endOfStream) {
349349
MediaFormat format = mVideoEncoder.getOutputFormat();
350350
mH264CodecSpecificData = EncoderUtils.getCodecSpecificData(format);
351351
} else {
352-
Log.w(TAG, "Output format change notified more than once, ignoring.");
352+
DebugTool.logWarning(TAG, "Output format change notified more than once, ignoring.");
353353
}
354354
}
355355
} else {
@@ -359,7 +359,7 @@ void drainEncoder(boolean endOfStream) {
359359
if (mH264CodecSpecificData != null) {
360360
mVideoBufferInfo.size = 0;
361361
} else {
362-
Log.i(TAG, "H264 codec specific data not retrieved yet.");
362+
DebugTool.logInfo(TAG, "H264 codec specific data not retrieved yet.");
363363
}
364364
}
365365

0 commit comments

Comments
 (0)