Browse Source

Conditional compile

tags/3.2
Gang Zhuo 9 years ago
parent
commit
a486514afb
1 changed files with 4 additions and 6 deletions
  1. +4
    -6
      shadowsocks-csharp/Controller/Logging.cs

+ 4
- 6
shadowsocks-csharp/Controller/Logging.cs View File

@@ -2,6 +2,7 @@
using System.IO; using System.IO;
using System.Net.Sockets; using System.Net.Sockets;
using System.Net; using System.Net;
using System.Diagnostics;
using Shadowsocks.Util; using Shadowsocks.Util;
@@ -47,16 +48,15 @@ namespace Shadowsocks.Controller
WriteToLogFile(o); WriteToLogFile(o);
} }
[Conditional("DEBUG")]
public static void Debug(object o) public static void Debug(object o)
{ {
#if DEBUG
WriteToLogFile("[D] " + o); WriteToLogFile("[D] " + o);
#endif
} }
[Conditional("DEBUG")]
public static void Debug(EndPoint local, EndPoint remote, int len, string header = null, string tailer = null) public static void Debug(EndPoint local, EndPoint remote, int len, string header = null, string tailer = null)
{ {
#if DEBUG
if (header == null && tailer == null) if (header == null && tailer == null)
Debug($"{local} => {remote} (size={len})"); Debug($"{local} => {remote} (size={len})");
else if (header == null && tailer != null) else if (header == null && tailer != null)
@@ -65,14 +65,12 @@ namespace Shadowsocks.Controller
Debug($"{header}: {local} => {remote} (size={len})"); Debug($"{header}: {local} => {remote} (size={len})");
else else
Debug($"{header}: {local} => {remote} (size={len}), {tailer}"); Debug($"{header}: {local} => {remote} (size={len}), {tailer}");
#endif
} }
[Conditional("DEBUG")]
public static void Debug(Socket sock, int len, string header = null, string tailer = null) public static void Debug(Socket sock, int len, string header = null, string tailer = null)
{ {
#if DEBUG
Debug(sock.LocalEndPoint, sock.RemoteEndPoint, len, header, tailer); Debug(sock.LocalEndPoint, sock.RemoteEndPoint, len, header, tailer);
#endif
} }
public static void LogUsefulException(Exception e) public static void LogUsefulException(Exception e)


Loading…
Cancel
Save