[Modify] Polish it

This commit is contained in:
sta 2015-11-06 16:52:11 +09:00
parent 7f833eab38
commit 3f38dad3cd

View File

@ -4,7 +4,7 @@
* *
* The MIT License * The MIT License
* *
* Copyright (c) 2013-2014 sta.blockhead * Copyright (c) 2013-2015 sta.blockhead
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -125,24 +125,23 @@ namespace WebSocketSharp
var type = method.DeclaringType; var type = method.DeclaringType;
#if DEBUG #if DEBUG
var lineNum = _caller.GetFileLineNumber (); var lineNum = _caller.GetFileLineNumber ();
var headerAndCaller = String.Format ( var headerAndCaller =
"{0}{1}.{2}:{3}|", header, type.Name, method.Name, lineNum); String.Format ("{0}{1}.{2}:{3}|", header, type.Name, method.Name, lineNum);
#else #else
var headerAndCaller = String.Format ("{0}{1}.{2}|", header, type.Name, method.Name); var headerAndCaller = String.Format ("{0}{1}.{2}|", header, type.Name, method.Name);
#endif #endif
var msgs = _message.Replace ("\r\n", "\n").TrimEnd ('\n').Split ('\n'); var msgs = _message.Replace ("\r\n", "\n").TrimEnd ('\n').Split ('\n');
if (msgs.Length <= 1) if (msgs.Length <= 1)
return String.Format ("{0}{1}", headerAndCaller, _message); return String.Format ("{0}{1}", headerAndCaller, _message);
var output = new StringBuilder (String.Format ("{0}{1}\n", headerAndCaller, msgs[0]), 64); var buff = new StringBuilder (String.Format ("{0}{1}\n", headerAndCaller, msgs[0]), 64);
var fmt = String.Format ("{{0,{0}}}{{1}}\n", header.Length); var fmt = String.Format ("{{0,{0}}}{{1}}\n", header.Length);
for (var i = 1; i < msgs.Length; i++) for (var i = 1; i < msgs.Length; i++)
output.AppendFormat (fmt, "", msgs[i]); buff.AppendFormat (fmt, "", msgs[i]);
output.Length--; buff.Length--;
return output.ToString (); return buff.ToString ();
} }
#endregion #endregion