Skip to content

Commit

Permalink
remove tag
Browse files Browse the repository at this point in the history
  • Loading branch information
ohmae committed Jun 7, 2017
1 parent 1f26074 commit 3c5011c
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 47 deletions.
6 changes: 2 additions & 4 deletions lib/src/main/java/net/mm2d/upnp/Action.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
* @author <a href="mailto:ryo@mm2d.net">大前良介(OHMAE Ryosuke)</a>
*/
public class Action {
private static final String TAG = Action.class.getSimpleName();

/**
* ServiceDescriptionのパース時に使用するビルダー
*
Expand Down Expand Up @@ -365,7 +363,7 @@ private Map<String, String> invokeInner(@Nonnull final String soap)
final HttpClient client = createHttpClient();
final HttpResponse response = client.post(request);
if (response.getStatus() != Http.Status.HTTP_OK || response.getBody() == null) {
Log.w(TAG, response.toString());
Log.w(response.toString());
throw new IOException(response.getStartLine());
}
try {
Expand Down Expand Up @@ -512,7 +510,7 @@ private Map<String, String> parseResponse(@Nonnull final String xml)
final String text = node.getTextContent();
if (findArgument(tag) == null) {
// Optionalな情報としてArgumentに記述されていないタグが含まれる可能性があるためログ出力に留める
Log.d(TAG, "invalid argument:" + tag + "->" + text);
Log.d("invalid argument:" + tag + "->" + text);
}
result.put(tag, text);
}
Expand Down
12 changes: 5 additions & 7 deletions lib/src/main/java/net/mm2d/upnp/ControlPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
* @author <a href="mailto:ryo@mm2d.net">大前良介(OHMAE Ryosuke)</a>
*/
public class ControlPoint {
private static final String TAG = ControlPoint.class.getSimpleName();

/**
* 機器発見イベント通知用リスナー。
*
Expand Down Expand Up @@ -226,7 +224,7 @@ public void run() {
private void notifyEvent(@Nullable final String name, @Nullable final String value) {
final StateVariable variable = mService.findStateVariable(name);
if (variable == null || !variable.isSendEvents() || value == null) {
Log.w(TAG, "illegal notify argument:" + name + " " + value);
Log.w("illegal notify argument:" + name + " " + value);
return;
}
mNotifyEventListenerList.onNotifyEvent(mService, mSeq, variable.getName(), value);
Expand Down Expand Up @@ -380,7 +378,7 @@ public void terminate() {
mCachedThreadPool.shutdownNow();
}
} catch (final InterruptedException e) {
Log.w(TAG, e);
Log.w(e);
}
mSubscribeHolder.shutdownRequest();
mDeviceHolder.shutdownRequest();
Expand All @@ -404,8 +402,8 @@ public void start() {
}
try {
mEventReceiver.open();
} catch (final IOException e1) {
Log.w(TAG, e1);
} catch (final IOException e) {
Log.w(e);
}
mSearchList.openAndStart();
mNotifyList.openAndStart();
Expand All @@ -432,7 +430,7 @@ public void run() {
try {
service.unsubscribe();
} catch (final IOException e) {
Log.w(TAG, e);
Log.w(e);
}
}
});
Expand Down
3 changes: 1 addition & 2 deletions lib/src/main/java/net/mm2d/upnp/DeviceHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
* @author <a href="mailto:ryo@mm2d.net">大前良介(OHMAE Ryosuke)</a>
*/
class DeviceHolder implements Runnable {
private static final String TAG = DeviceHolder.class.getSimpleName();
private static final long MARGIN_TIME = TimeUnit.SECONDS.toMillis(10);

@Nonnull
Expand Down Expand Up @@ -55,7 +54,7 @@ class DeviceHolder implements Runnable {
void start() {
mShutdownRequest = false;
synchronized (mThreadLock) {
mThread = new Thread(this, TAG);
mThread = new Thread(this, getClass().getSimpleName());
mThread.start();
}
}
Expand Down
4 changes: 1 addition & 3 deletions lib/src/main/java/net/mm2d/upnp/EventReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
* @author <a href="mailto:ryo@mm2d.net">大前良介(OHMAE Ryosuke)</a>
*/
class EventReceiver {
private static final String TAG = EventReceiver.class.getSimpleName();

/**
* イベントデータの受信を受け取るリスナー。
*/
Expand Down Expand Up @@ -326,7 +324,7 @@ public void run() {
os = mSocket.getOutputStream();
receiveAndReply(is, os);
} catch (final IOException e) {
Log.w(TAG, e);
Log.w(e);
} finally {
IoUtils.closeQuietly(is);
IoUtils.closeQuietly(os);
Expand Down
3 changes: 1 addition & 2 deletions lib/src/main/java/net/mm2d/upnp/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
* @author <a href="mailto:ryo@mm2d.net">大前良介(OHMAE Ryosuke)</a>
*/
public class HttpClient {
private static final String TAG = HttpClient.class.getSimpleName();
private static final int REDIRECT_MAX = 2;
@Nullable
private Socket mSocket;
Expand Down Expand Up @@ -275,7 +274,7 @@ public HttpResponse download(@Nonnull final URL url) throws IOException {
final HttpRequest request = makeHttpRequest(url);
final HttpResponse response = post(request);
if (response.getStatus() != Http.Status.HTTP_OK || TextUtils.isEmpty(response.getBody())) {
Log.i(TAG, "request:" + request.toString() + "\nresponse:" + response.toString());
Log.i("request:" + request.toString() + "\nresponse:" + response.toString());
throw new IOException(response.getStartLine());
}
return response;
Expand Down
9 changes: 4 additions & 5 deletions lib/src/main/java/net/mm2d/upnp/HttpMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
* @see HttpRequest
*/
public abstract class HttpMessage {
private static final String TAG = HttpMessage.class.getSimpleName();
private static final int BUFFER_SIZE = 1500;
private static final int DEFAULT_CHUNK_SIZE = 1024;
private static final int CR = 0x0d;
Expand Down Expand Up @@ -269,7 +268,7 @@ public int getContentLength() {
try {
return Integer.parseInt(len);
} catch (final NumberFormatException e) {
Log.w(TAG, e);
Log.w(e);
}
}
return 0;
Expand Down Expand Up @@ -325,7 +324,7 @@ private void setBodyInner(@Nullable final String string,
try {
mBodyBinary = string.getBytes(CHARSET);
} catch (final UnsupportedEncodingException e) {
Log.w(TAG, e);
Log.w(e);
}
}
if (withContentLength) {
Expand All @@ -345,7 +344,7 @@ public String getBody() {
try {
mBody = new String(mBodyBinary, CHARSET);
} catch (final UnsupportedEncodingException e) {
Log.w(TAG, e);
Log.w(e);
}
}
return mBody;
Expand Down Expand Up @@ -399,7 +398,7 @@ private byte[] getHeaderBytes() {
try {
return getHeaderString().getBytes(CHARSET);
} catch (final UnsupportedEncodingException e) {
Log.w(TAG, e);
Log.w(e);
}
return new byte[0];
}
Expand Down
14 changes: 6 additions & 8 deletions lib/src/main/java/net/mm2d/upnp/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
* @author <a href="mailto:ryo@mm2d.net">大前良介(OHMAE Ryosuke)</a>
*/
public class Service {
private static final String TAG = Service.class.getSimpleName();

/**
* DeviceDescriptionのパース時に使用するビルダー
*/
Expand Down Expand Up @@ -482,7 +480,7 @@ private static long parseTimeout(@Nonnull final HttpResponse response) {
final int second = Integer.parseInt(secondSection);
return TimeUnit.SECONDS.toMillis(second);
} catch (final NumberFormatException e) {
Log.w(TAG, e);
Log.w(e);
}
return DEFAULT_SUBSCRIPTION_TIMEOUT;
}
Expand Down Expand Up @@ -533,7 +531,7 @@ private boolean subscribeInner(final boolean keepRenew) throws IOException {
final HttpRequest request = makeSubscribeRequest();
final HttpResponse response = client.post(request);
if (response.getStatus() != Http.Status.HTTP_OK) {
Log.w(TAG, "subscribe request:" + request.toString() + "\nresponse:" + response.toString());
Log.w("subscribe request:" + request.toString() + "\nresponse:" + response.toString());
return false;
}
if (parseSubscribeResponse(response)) {
Expand All @@ -547,7 +545,7 @@ private boolean parseSubscribeResponse(@Nonnull final HttpResponse response) {
final String sid = response.getHeader(Http.SID);
final long timeout = parseTimeout(response);
if (TextUtils.isEmpty(sid) || timeout == 0) {
Log.w(TAG, "subscribe response:" + response.toString());
Log.w("subscribe response:" + response.toString());
return false;
}
mSubscriptionId = sid;
Expand Down Expand Up @@ -591,7 +589,7 @@ private boolean renewSubscribeInner() throws IOException {
final HttpRequest request = makeRenewSubscribeRequest(mSubscriptionId);
final HttpResponse response = client.post(request);
if (response.getStatus() != Http.Status.HTTP_OK) {
Log.w(TAG, "renewSubscribe request:" + request.toString() + "\nresponse:" + response.toString());
Log.w("renewSubscribe request:" + request.toString() + "\nresponse:" + response.toString());
return false;
}
return parseRenewSubscribeResponse(response);
Expand All @@ -601,7 +599,7 @@ private boolean parseRenewSubscribeResponse(@Nonnull final HttpResponse response
final String sid = response.getHeader(Http.SID);
final long timeout = parseTimeout(response);
if (!TextUtils.equals(sid, mSubscriptionId) || timeout == 0) {
Log.w(TAG, "renewSubscribe response:" + response.toString());
Log.w("renewSubscribe response:" + response.toString());
return false;
}
mSubscriptionStart = System.currentTimeMillis();
Expand Down Expand Up @@ -635,7 +633,7 @@ public boolean unsubscribe() throws IOException {
final HttpRequest request = makeUnsubscribeRequest(mSubscriptionId);
final HttpResponse response = client.post(request);
if (response.getStatus() != Http.Status.HTTP_OK) {
Log.w(TAG, "unsubscribe request:" + request.toString() + "\nresponse:" + response.toString());
Log.w("unsubscribe request:" + request.toString() + "\nresponse:" + response.toString());
return false;
}
mControlPoint.unregisterSubscribeService(this);
Expand Down
4 changes: 1 addition & 3 deletions lib/src/main/java/net/mm2d/upnp/SsdpNotifyReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
* @author <a href="mailto:ryo@mm2d.net">大前良介(OHMAE Ryosuke)</a>
*/
class SsdpNotifyReceiver extends SsdpServer {
private static final String TAG = SsdpNotifyReceiver.class.getSimpleName();

/**
* NOTIFY受信を受け取るリスナー。
*/
Expand Down Expand Up @@ -66,7 +64,7 @@ protected void onReceive(@Nonnull final InetAddress sourceAddress,
// セグメント情報が間違っており、マルチキャスト以外のやり取りができない相手からのパケットは
// 受け取っても無駄なので破棄する。
if (!isSameSegment(getInterfaceAddress(), sourceAddress)) {
Log.w(TAG, "Invalid segment packet received:" + sourceAddress.toString()
Log.w("Invalid segment packet received:" + sourceAddress.toString()
+ " " + getInterfaceAddress().toString());
return;
}
Expand Down
3 changes: 1 addition & 2 deletions lib/src/main/java/net/mm2d/upnp/SsdpNotifyReceiverList.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* @author <a href="mailto:ryo@mm2d.net">大前良介(OHMAE Ryosuke)</a>
*/
class SsdpNotifyReceiverList {
private static final String TAG = SsdpNotifyReceiverList.class.getSimpleName();
@Nonnull
private final List<SsdpNotifyReceiver> mList;

Expand All @@ -44,7 +43,7 @@ void openAndStart() {
receiver.open();
receiver.start();
} catch (final IOException e) {
Log.w(TAG, e);
Log.w(e);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions lib/src/main/java/net/mm2d/upnp/SsdpSearchServerList.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
* @author <a href="mailto:ryo@mm2d.net">大前良介(OHMAE Ryosuke)</a>
*/
class SsdpSearchServerList {
private static final String TAG = SsdpSearchServerList.class.getSimpleName();
@Nonnull
private final List<SsdpSearchServer> mList;

Expand All @@ -45,7 +44,7 @@ void openAndStart() {
server.open();
server.start();
} catch (final IOException e) {
Log.w(TAG, e);
Log.w(e);
}
}
}
Expand Down
8 changes: 3 additions & 5 deletions lib/src/main/java/net/mm2d/upnp/SsdpServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
*/
// TODO: SocketChannelを使用した受信(MulticastChannelはAndroid N以降のため保留)
abstract class SsdpServer {
private static final String TAG = SsdpServer.class.getSimpleName();
/**
* SSDPに使用するアドレス。
*/
Expand Down Expand Up @@ -112,7 +111,7 @@ void open() throws IOException {
}

@Nonnull
// VisibleForTesting
// VisibleForTesting
MulticastSocket createMulticastSocket(final int port) throws IOException {
return new MulticastSocket(port);
}
Expand Down Expand Up @@ -171,7 +170,7 @@ void send(@Nonnull final SsdpMessage message) {
message.getMessage().writeData(baos);
send(baos.toByteArray());
} catch (final IOException e) {
Log.w(TAG, e);
Log.w(e);
}
}

Expand All @@ -194,7 +193,6 @@ private void send(@Nonnull final byte[] message) throws IOException {
protected abstract void onReceive(@Nonnull InetAddress sourceAddress, @Nonnull byte[] data, int length);

private static class ReceiveTask implements Runnable {
private static final String TAG = ReceiveTask.class.getSimpleName();
@Nonnull
private final SsdpServer mSsdpServer;
@Nonnull
Expand All @@ -220,7 +218,7 @@ private static class ReceiveTask implements Runnable {
*/
synchronized void start() {
mShutdownRequest = false;
mThread = new Thread(this, TAG);
mThread = new Thread(this, getClass().getSimpleName());
mThread.start();
}

Expand Down
3 changes: 1 addition & 2 deletions lib/src/main/java/net/mm2d/upnp/SubscribeHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
* @author <a href="mailto:ryo@mm2d.net">大前良介(OHMAE Ryosuke)</a>
*/
class SubscribeHolder implements Runnable {
private static final String TAG = SubscribeHolder.class.getSimpleName();
private static final long MIN_INTERVAL = TimeUnit.SECONDS.toMillis(1);

private final Object mThreadLock = new Object();
Expand All @@ -45,7 +44,7 @@ class SubscribeHolder implements Runnable {
void start() {
mShutdownRequest = false;
synchronized (mThreadLock) {
mThread = new Thread(this, TAG);
mThread = new Thread(this, getClass().getSimpleName());
mThread.start();
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/main/java/net/mm2d/util/Log.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public static void setLogLevel(final int level) {
*
* @param append 追加する場合true
*/
public static void setAppendCaller(boolean append) {
public static void setAppendCaller(final boolean append) {
sAppendCaller = append;
}

Expand Down Expand Up @@ -398,7 +398,7 @@ private static void println(
}

@Nonnull
private static String makeTag(@Nullable final String tag, @Nullable StackTraceElement element) {
private static String makeTag(@Nullable final String tag, @Nullable final StackTraceElement element) {
if (tag != null) {
return tag;
}
Expand Down

0 comments on commit 3c5011c

Please sign in to comment.