Log.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using System.Diagnostics;
  3. namespace Log
  4. {
  5. public static class Log
  6. {
  7. public static void D(string message)
  8. {
  9. var sf = new StackFrame(1, true);
  10. string log = string.Format(
  11. "{0} {1} Line:{2} {3} [D]: {4}",
  12. System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13. sf.GetFileName(),
  14. sf.GetFileLineNumber(),
  15. sf.GetMethod(),
  16. message
  17. );
  18. Debug.WriteLine(log);
  19. }
  20. public static void D(string message, params object[] args)
  21. {
  22. string info = String.Format(message, args);
  23. var sf = new StackFrame(1, true);
  24. string log = string.Format(
  25. "{0} {1} Line:{2} {3} [D]: {4}",
  26. System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  27. sf.GetFileName(),
  28. sf.GetFileLineNumber(),
  29. sf.GetMethod(),
  30. info
  31. );
  32. Debug.WriteLine(log);
  33. }
  34. public static void E(string message)
  35. {
  36. var sf = new StackFrame(1, true);
  37. string log = string.Format(
  38. "{0} {1} Line:{2} {3} [E]: {4}",
  39. System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  40. sf.GetFileName(),
  41. sf.GetFileLineNumber(),
  42. sf.GetMethod(),
  43. message
  44. );
  45. Debug.WriteLine(log);
  46. }
  47. public static void E(string message, params object[] args)
  48. {
  49. string info = String.Format(message, args);
  50. var sf = new StackFrame(1, true);
  51. string log = string.Format(
  52. "{0} {1} Line:{2} {3} [E]: {4}",
  53. System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  54. sf.GetFileName(),
  55. sf.GetFileLineNumber(),
  56. sf.GetMethod(),
  57. info
  58. );
  59. Debug.WriteLine(log);
  60. }
  61. }
  62. }