LogTool.cs 710 B

123456789101112131415161718192021222324252627282930313233343536
  1. using Hotline.Settings;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace Hotline.Tools
  8. {
  9. public class LogTool
  10. {
  11. /// <summary>
  12. /// 截取指定长度的字符串
  13. /// </summary>
  14. /// <param name="value"></param>
  15. /// <param name="length"></param>
  16. /// <param name="ellipsis"></param>
  17. /// <returns></returns>
  18. public static string GetSubString(string value, int length, bool ellipsis = false)
  19. {
  20. if (string.IsNullOrEmpty(value))
  21. {
  22. return value;
  23. }
  24. if (value.Length > length)
  25. {
  26. value = value.Substring(0, length);
  27. if (ellipsis)
  28. {
  29. value += "...";
  30. }
  31. }
  32. return value;
  33. }
  34. }
  35. }