The Free Software Media System - Server Backend & API
add missing file
Luke Pulverenti71adae0903ce
diff --git a/Emby.Common.Implementations/Emby.Common.Implementations.csproj b/Emby.Common.Implementations/Emby.Common.Implementations.csprojindex 00c90d16e4..5b1defccb5 100644--- a/Emby.Common.Implementations/Emby.Common.Implementations.csproj+++ b/Emby.Common.Implementations/Emby.Common.Implementations.csproj@@ -228,6 +228,7 @@<Compile Include="IO\SharpCifs\Smb\WinError.cs" /><Compile Include="IO\SharpCifs\UniAddress.cs" /><Compile Include="IO\SharpCifs\Util\Base64.cs" />+ <Compile Include="IO\SharpCifs\Util\DbsHelper\Log.cs" /><Compile Include="IO\SharpCifs\Util\DES.cs" /><Compile Include="IO\SharpCifs\Util\Encdec.cs" /><Compile Include="IO\SharpCifs\Util\Hexdump.cs" />diff --git a/Emby.Common.Implementations/IO/SharpCifs/Util/DbsHelper/Log.cs b/Emby.Common.Implementations/IO/SharpCifs/Util/DbsHelper/Log.csnew file mode 100644index 0000000000..eebf7c6b21--- /dev/null+++ b/Emby.Common.Implementations/IO/SharpCifs/Util/DbsHelper/Log.cs@@ -0,0 +1,118 @@+using System;+using System.Collections.Generic;+using System.Diagnostics;+using System.Linq;+using System.Text;+using System.Threading.Tasks;+++namespace SharpCifs.Util.DbsHelper+{+ public class Log+ {+ /// <summary>+ /// コンソールへのログ出力を行うか否か+ /// </summary>+ public static bool IsActive { get; set; } = false;++ public static void Out(string message)+ {+ if (!Log.IsActive+ || string.IsNullOrEmpty(message))+ return;++ var msg = DateTime.Now.ToString("HH:mm:ss.fff")+ + ": [ThID: "+ + System.Environment.CurrentManagedThreadId.ToString().PadLeft(3)+ + " "+ + message;++ Debug.WriteLine(msg);+ Console.WriteLine(msg);+ }++ /// <summary>+ /// 例外のログ出力を行う。+ /// </summary>+ /// <param name="ex"></param>+ public static void Out(Exception ex)+ {+ if (!Log.IsActive+ || ex == null)+ return;++ Log.Out($"{ex}");+ var message = Log.GetHighlighted(Log.GetErrorString(ex));+ Log.Out(message);+ }++ /// <summary>+ /// Cast string-arrary to Highlighted message+ /// 文字列配列を強調メッセージ形式文字列に変換する。+ /// </summary>+ /// <param name="messages"></param>+ /// <returns></returns>+ private static string GetHighlighted(params System.String[] messages)+ {+ var time = DateTime.Now;+ var list = new List<string>();++ list.Add("");+ list.Add("");+ list.Add(time.ToString("HH:mm:ss.fff") + ":");+ list.Add("##################################################");+ list.Add("#");++ foreach (string message in messages)+ {+ var lines = message.Replace("\r\n", "\n").Replace("\r", "\n").Trim('\n').Split('\n');+ foreach (var line in lines)+ {+ list.Add($"# {line}");+ }+ }++ list.Add("#");+ list.Add("##################################################");+ list.Add("");+ list.Add("");++ return string.Join("\r\n", list);+ }++ /// <summary>+ /// Get Formatted Exception-Info string-array+ /// 例外情報を整形した文字列配列を返す。+ /// </summary>+ /// <param name="ex"></param>+ /// <returns></returns>+ private static string[] GetErrorString(Exception ex)+ {+ var list = new List<string>();++ if (ex.Message != null)+ {+ list.Add(ex.Message ?? "");+ list.Add("");+ }++ if (ex.StackTrace != null)+ {+ list.AddRange(ex.StackTrace.Split(new string[] { "場所", "at " },+ StringSplitOptions.None)+ .AsEnumerable()+ .Select(row => "\r\nat " + row));+ }++ if (ex.InnerException != null)+ {+ //InnerExceptionを再帰取得する。+ list.Add("");+ list.Add("Inner Exception");+ list.AddRange(Log.GetErrorString(ex.InnerException));+ }++ return list.ToArray();+ }+ }+}