51 lines
1.6 KiB
C#
51 lines
1.6 KiB
C#
using Nirvana.Common;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace YBDevice.Service.DBServices
|
|
{
|
|
/// <summary>
|
|
/// 日志记录
|
|
/// </summary>
|
|
public class LoggerApp
|
|
{
|
|
/// <summary>
|
|
/// 记录文本日志
|
|
/// </summary>
|
|
/// <param name="msg"></param>
|
|
/// <param name="type"></param>
|
|
public void InsertErrorLog(string msg, int type = 1)
|
|
{
|
|
LogFactory.InsertErrorLog(msg, type);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 记录文本日志
|
|
/// </summary>ye m
|
|
/// <param name="param">参数</param>
|
|
/// <param name="ex">异常</param>
|
|
/// <param name="type">类型</param>
|
|
/// <param name="program">程序名称</param>
|
|
public void InsertErrorLog(Exception ex, string param = "", string program = "", int type = 1)
|
|
{
|
|
var msg = $"ex:{ex.Message},source:{ex.Source}\r\nstack:{ex.StackTrace}";
|
|
if (ex.InnerException != null)
|
|
{
|
|
msg = $"{msg}\r\nInnerException.Message:{ex.InnerException.Message},InnerException.Source:{ex.InnerException.Source}\r\nInnerException.StackTrace:{ex.InnerException.StackTrace}";
|
|
}
|
|
if (!string.IsNullOrEmpty(param))
|
|
{
|
|
msg = $"参数:{param}\r\n{msg}";
|
|
}
|
|
if (!string.IsNullOrEmpty(program))
|
|
{
|
|
msg = $"{program}:{msg}";
|
|
}
|
|
InsertErrorLog(msg, type);
|
|
}
|
|
}
|
|
}
|