mirror of
https://github.com/KevinWG/OSS.Common.git
synced 2026-10-29 14:10:30 +08:00
优化日志插件
This commit is contained in:
@@ -74,9 +74,8 @@ namespace OSS.Common.Authrization
|
||||
/// </summary>
|
||||
public string Sign { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 扩展参数 【自定义,不参与签名】
|
||||
/// 内部扩展参数 【自定义,不参与签名和传递】
|
||||
/// </summary>
|
||||
public object Extra { get; set; }
|
||||
|
||||
@@ -96,8 +95,7 @@ namespace OSS.Common.Authrization
|
||||
/// 租户ID 【仅 InnerProxy 时,才会通过外部传值,不参与签名】
|
||||
/// </summary>
|
||||
public long TenantId { get; set; }
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 字符串处理
|
||||
@@ -167,7 +165,6 @@ namespace OSS.Common.Authrization
|
||||
case "tt":
|
||||
TenantToken = val;
|
||||
break;
|
||||
|
||||
|
||||
case "sign":
|
||||
Sign = val;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
|
||||
<Version>1.3.3.1</Version>
|
||||
<Version>1.3.3.2</Version>
|
||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||
<Authors>Kevin</Authors>
|
||||
<Company>OSSCoder</Company>
|
||||
@@ -13,9 +13,9 @@
|
||||
<PackageIconUrl>http://img1.static.osscoder.com/logo.jpg</PackageIconUrl>
|
||||
<RepositoryUrl>https://github.com/KevinWG/OSS.Common</RepositoryUrl>
|
||||
|
||||
<PackageReleaseNotes>优化签名算法和属性</PackageReleaseNotes>
|
||||
<AssemblyVersion>1.3.3.1</AssemblyVersion>
|
||||
<FileVersion>1.3.3.1</FileVersion>
|
||||
<PackageReleaseNotes>优化日志插件</PackageReleaseNotes>
|
||||
<AssemblyVersion>1.3.3.2</AssemblyVersion>
|
||||
<FileVersion>1.3.3.2</FileVersion>
|
||||
|
||||
<PackageLicenseUrl>https://github.com/KevinWG/OSS.Common/blob/master/LICENSE</PackageLicenseUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OSS.Common.ComUtils;
|
||||
|
||||
namespace OSS.Common.Plugs.LogPlug
|
||||
@@ -51,7 +52,7 @@ namespace OSS.Common.Plugs.LogPlug
|
||||
return Path.Combine(dirPath, DateTime.Now.ToString("yyyyMMddHH")+".txt");
|
||||
}
|
||||
|
||||
private readonly object obj = new object();
|
||||
private static readonly object obj = new object();
|
||||
|
||||
/// <summary>
|
||||
/// 写日志
|
||||
@@ -59,23 +60,28 @@ namespace OSS.Common.Plugs.LogPlug
|
||||
/// <param name="info"></param>
|
||||
public void WriteLog(LogInfo info)
|
||||
{
|
||||
lock (obj)
|
||||
Task.Run(() =>
|
||||
{
|
||||
var filePath = getLogFilePath(info.ModuleName, info.Level);
|
||||
lock (obj)
|
||||
{
|
||||
var filePath = getLogFilePath(info.ModuleName, info.Level);
|
||||
#if NETFW
|
||||
using (StreamWriter sw = new StreamWriter(filePath, true, Encoding.UTF8))
|
||||
#else
|
||||
using (StreamWriter sw = new StreamWriter(new FileStream(filePath,FileMode.Append,FileAccess.Write), Encoding.UTF8))
|
||||
using (StreamWriter sw =
|
||||
new StreamWriter(new FileStream(filePath, FileMode.Append, FileAccess.Write), Encoding.UTF8))
|
||||
#endif
|
||||
{
|
||||
sw.WriteLine( _logFormat,
|
||||
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
info.LogCode,
|
||||
info.MsgKey,
|
||||
info.Msg);
|
||||
|
||||
{
|
||||
sw.WriteLine(_logFormat,
|
||||
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
info.LogCode,
|
||||
info.MsgKey,
|
||||
info.Msg);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace OSS.Common.Plugs.LogPlug
|
||||
/// 跟踪查看
|
||||
/// </summary>
|
||||
Trace,
|
||||
|
||||
/// <summary>
|
||||
/// 信息
|
||||
/// </summary>
|
||||
@@ -169,13 +170,12 @@ namespace OSS.Common.Plugs.LogPlug
|
||||
info.ModuleName = ModuleNames.Default;
|
||||
|
||||
var logWrite = GetLogWrite(info.ModuleName);
|
||||
logWrite.SetLogCode(info);
|
||||
|
||||
Task.Run(() => logWrite.WriteLog(info));
|
||||
logWrite.SetLogCode(info);
|
||||
logWrite.WriteLog(info);
|
||||
|
||||
return info.LogCode;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user