对已LogHelper,形如:

public static void WriteError(string className,string methodName,string message)
{
    //...
}

public static void WriteDebug(string className, string methodName, string message)
{
    //...
}

大家都知道要干嘛,调用时这样的:

LogHelper.WriteDebug("BusFlowBase", "DoWork", string.Format("公司在平台查询订单查询完毕。"));

2.简化之后

public static void WriteError(string message)
{
   var sf = new StackFrame(1);   //1表示离栈顶还差一个。
    var callMethod = sf.GetMethod();
    WriteError(callMethod.DeclaringType.Name, callMethod.Name, message);
}

public static void WriteError(string className, string methodName, string message)
{
    //...
}

public static void WriteDebug(string message)
{
    var sf = new StackFrame(1); 
    var callMethod = sf.GetMethod();
    WriteDebug(callMethod.DeclaringType.Name, callMethod.Name, message);
}
public static void WriteDebug(string className, string methodName, string message)
{
    //...
}

调用时这样的:

LogHelper.WriteDebug( string.Format("公司在平台查询订单查询完毕。"));

 

舒服吧?!!!

相关文章:

  • 2021-08-21
  • 2021-05-23
  • 2021-11-05
  • 2022-03-09
  • 2022-02-12
  • 2021-07-27
  • 2021-05-06
  • 2021-06-05
猜你喜欢
  • 2019-05-26
  • 2021-12-05
  • 2021-11-11
  • 2021-09-27
  • 2021-10-03
相关资源
相似解决方案