removed dtlib internal logging
This commit is contained in:
parent
d54316ca61
commit
81e4238b1c
@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<!--package info-->
|
||||
<PackageId>DTLib.Dtsod</PackageId>
|
||||
<Version>1.3.0</Version>
|
||||
<Version>1.3.1</Version>
|
||||
<Authors>Timerix</Authors>
|
||||
<Description>Definitely not json</Description>
|
||||
<RepositoryType>GIT</RepositoryType>
|
||||
@ -11,7 +11,7 @@
|
||||
<Configuration>Release</Configuration>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<!--compilation properties-->
|
||||
<TargetFrameworks>netstandard2.0;net48;net6.0;net7.0</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||
<DebugType>embedded</DebugType>
|
||||
<!--language features-->
|
||||
<LangVersion>11</LangVersion>
|
||||
@ -33,7 +33,7 @@
|
||||
<ProjectReference Include="..\DTLib\DTLib.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
|
||||
<PackageReference Include="DTLib" Version="1.3.0" />
|
||||
<PackageReference Include="DTLib" Version="1.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--project files-->
|
||||
|
||||
@ -16,12 +16,12 @@ public static class DtsodConverter
|
||||
};
|
||||
|
||||
// заменяет дефолтные значения на пользовательские
|
||||
public static DtsodV23 UpdateByDefault(DtsodV23 old, DtsodV23 updatedDefault, string contextName="")
|
||||
public static DtsodV23 UpdateByDefault(DtsodV23 old, DtsodV23 updatedDefault, string contextName = "")
|
||||
{
|
||||
DtsodV23 updated = new();
|
||||
foreach (KeyValuePair<string,dynamic> p in updatedDefault)
|
||||
foreach (KeyValuePair<string, dynamic> p in updatedDefault)
|
||||
{
|
||||
string keyWithContext=contextName+"."+p.Key;
|
||||
string keyWithContext = contextName + "." + p.Key;
|
||||
if (old.TryGetValue(p.Key, out var oldValue))
|
||||
{
|
||||
if (oldValue.GetType() != p.Value.GetType())
|
||||
@ -29,27 +29,16 @@ public static class DtsodConverter
|
||||
"uncompatible config value type\n " +
|
||||
$"<{keyWithContext}>: {oldValue} is {oldValue.GetType()}, " +
|
||||
$"must be {p.Value.GetType()}");
|
||||
else
|
||||
if (oldValue is DtsodV23)
|
||||
{
|
||||
if(oldValue!=p.Value)
|
||||
Log("y", $"<{keyWithContext}> old: {oldValue} new: {p.Value}");
|
||||
if(oldValue is DtsodV23){
|
||||
var subdtsod=UpdateByDefault(oldValue, p.Value, keyWithContext);
|
||||
updated.Add(p.Key,subdtsod);
|
||||
var subdtsod = UpdateByDefault(oldValue, p.Value, keyWithContext);
|
||||
updated.Add(p.Key, subdtsod);
|
||||
}
|
||||
else if(oldValue is IList)
|
||||
{
|
||||
Log("y", $"can't automatically update list <{keyWithContext}>, do it manually");
|
||||
updated.Add(p.Key,oldValue);
|
||||
}
|
||||
else updated.Add(p.Key,oldValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("y", $"<{keyWithContext}> new: {p.Value}");
|
||||
updated.Add(p.Key,p.Value);
|
||||
else if (oldValue is IList)
|
||||
updated.Add(p.Key, oldValue);
|
||||
else updated.Add(p.Key, oldValue);
|
||||
}
|
||||
else updated.Add(p.Key, p.Value);
|
||||
}
|
||||
|
||||
return updated;
|
||||
|
||||
@ -213,7 +213,6 @@ public class DtsodV23 : DtsodDict<string, dynamic>, IDtsod
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
Log("r", $"can't parse value: {value_str}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ global using System.Collections.Generic;
|
||||
global using System.Linq;
|
||||
global using System.Text;
|
||||
global using DTLib.Extensions;
|
||||
global using static DTLib.Logging.InternalLog;
|
||||
|
||||
namespace DTLib.Dtsod;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<!--package info-->
|
||||
<PackageId>DTLib.Logging</PackageId>
|
||||
<Version>1.3.0</Version>
|
||||
<Version>1.3.1</Version>
|
||||
<Authors>Timerix</Authors>
|
||||
<Description>Loggers with dependency injection</Description>
|
||||
<RepositoryType>GIT</RepositoryType>
|
||||
@ -11,7 +11,7 @@
|
||||
<Configuration>Release</Configuration>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<!--compilation properties-->
|
||||
<TargetFrameworks>netstandard2.0;net48;net6.0;net7.0</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||
<DebugType>embedded</DebugType>
|
||||
<!--language features-->
|
||||
<LangVersion>10</LangVersion>
|
||||
@ -30,7 +30,7 @@
|
||||
<ProjectReference Include="..\DTLib.Ben.Demystifier\DTLib.Ben.Demystifier.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
|
||||
<PackageReference Include="DTLib" Version="1.3.0" />
|
||||
<PackageReference Include="DTLib" Version="1.3.1" />
|
||||
<PackageReference Include="DTLib.Ben.Demystifier" Version="1.0.4" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@ -1,37 +0,0 @@
|
||||
global using System;
|
||||
global using System.Collections;
|
||||
global using System.Collections.Generic;
|
||||
global using System.Runtime.CompilerServices;
|
||||
global using System.Linq;
|
||||
global using System.Text;
|
||||
global using System.Threading.Tasks;
|
||||
global using DTLib.Extensions;
|
||||
global using DTLib.Filesystem;
|
||||
|
||||
namespace DTLib.Logging;
|
||||
|
||||
/// this class can be used to setup logger for DTLib debug log messages
|
||||
public static class DTLibInternalLogging
|
||||
{
|
||||
private static ContextLogger _loggerContext;
|
||||
|
||||
public static void SetLogger(ILogger logger)
|
||||
{
|
||||
_loggerContext = new ContextLogger("DTLib",logger);
|
||||
InternalLog.LogEvent+=LogHandler;
|
||||
}
|
||||
|
||||
private static void LogHandler(string[] msg)
|
||||
{
|
||||
if (msg.Length == 1)
|
||||
{
|
||||
_loggerContext.LogDebug(msg[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder b = new();
|
||||
for (int i = 1; i < msg.Length; i++)
|
||||
b.Append(msg[i]);
|
||||
_loggerContext.LogDebug(b.ToString());
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,3 @@
|
||||
using DTLib.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
// ReSharper disable RedundantNameQualifier
|
||||
|
||||
|
||||
8
DTLib.Logging/GlobalUsings.cs
Normal file
8
DTLib.Logging/GlobalUsings.cs
Normal file
@ -0,0 +1,8 @@
|
||||
global using System;
|
||||
global using System.Collections.Generic;
|
||||
global using System.Runtime.CompilerServices;
|
||||
global using System.Linq;
|
||||
global using System.Text;
|
||||
global using System.Threading.Tasks;
|
||||
global using DTLib.Extensions;
|
||||
global using DTLib.Filesystem;
|
||||
@ -11,7 +11,7 @@
|
||||
<Configuration>Release</Configuration>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<!--compilation properties-->
|
||||
<TargetFrameworks>netstandard2.0;net48;net6.0;net7.0</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||
<DebugType>embedded</DebugType>
|
||||
<!--language features-->
|
||||
<LangVersion>10</LangVersion>
|
||||
@ -32,6 +32,6 @@
|
||||
<ProjectReference Include="..\DTLib.Dtsod\DTLib.Dtsod.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
|
||||
<PackageReference Include="DTLib.Dtsod" Version="1.3.0" />
|
||||
<PackageReference Include="DTLib.Dtsod" Version="1.3.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<!--compilation properties-->
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netstandard2.0;net48;net6.0;net7.0</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||
<DebugType>embedded</DebugType>
|
||||
<!--language features-->
|
||||
<LangVersion>10</LangVersion>
|
||||
@ -27,10 +27,10 @@
|
||||
<ProjectReference Include="..\DTLib\DTLib.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
|
||||
<PackageReference Include="DTLib" Version="1.3.0" />
|
||||
<PackageReference Include="DTLib.Dtsod" Version="1.3.0" />
|
||||
<PackageReference Include="DTLib.Network" Version="1.3.0" />
|
||||
<PackageReference Include="DTLib.Logging" Version="1.3.0" />
|
||||
<PackageReference Include="DTLib" Version="1.3.1" />
|
||||
<PackageReference Include="DTLib.Dtsod" Version="1.3.1" />
|
||||
<PackageReference Include="DTLib.Network" Version="1.3.1" />
|
||||
<PackageReference Include="DTLib.Logging" Version="1.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--project files-->
|
||||
|
||||
@ -29,7 +29,6 @@ public static class Program
|
||||
System.Console.OutputEncoding = Encoding.UTF8;
|
||||
System.Console.InputEncoding = Encoding.UTF8;
|
||||
var mainContext = new ContextLogger("Main", Logger);
|
||||
DTLibInternalLogging.SetLogger(Logger);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using DTLib.Logging;
|
||||
|
||||
namespace DTLib.Tests;
|
||||
|
||||
@ -13,6 +12,6 @@ public static class TesterLog
|
||||
operation();
|
||||
clock.Stop();
|
||||
double time=(double)(clock.ElapsedTicks)/Stopwatch.Frequency/repeats;
|
||||
InternalLog.Log("y",$"operation ","b",op_name,"y"," lasted ","b",time.ToString(MyTimeFormat.ForText),"y"," seconds");
|
||||
Logger.LogInfo(nameof(TesterLog), $"operation {op_name} lasted {time.ToString(MyTimeFormat.ForText)} seconds");
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<!--package info-->
|
||||
<PackageId>DTLib</PackageId>
|
||||
<Version>1.3.0</Version>
|
||||
<Version>1.3.1</Version>
|
||||
<Authors>Timerix</Authors>
|
||||
<Description>Library for all my C# projects</Description>
|
||||
<RepositoryType>GIT</RepositoryType>
|
||||
@ -11,7 +11,7 @@
|
||||
<Configuration>Release</Configuration>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<!--compilation properties-->
|
||||
<TargetFrameworks>netstandard2.0;net48;net6.0;net7.0</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||
<!--Platforms>AnyCPU;x64;x86;arm64</Platforms-->
|
||||
<!--Configurations>Debug;Release</Configurations-->
|
||||
<DebugType>embedded</DebugType>
|
||||
|
||||
@ -42,7 +42,6 @@ public static class DependencyResolver
|
||||
{
|
||||
var extracted = file.Substring(file.LastIndexOf(Path.Sep) + 1);
|
||||
File.Copy(file, extracted, true);
|
||||
Log("g", $"{file} extracted");
|
||||
}
|
||||
|
||||
DepsCopied = true;
|
||||
|
||||
@ -6,7 +6,6 @@ global using System.Text;
|
||||
global using System.Threading.Tasks;
|
||||
global using DTLib.Extensions;
|
||||
global using DTLib.Filesystem;
|
||||
global using static DTLib.Logging.InternalLog;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
namespace DTLib.Logging;
|
||||
|
||||
/// <summary>
|
||||
/// вывод логов со всех классов в библиотеке
|
||||
/// </summary>
|
||||
public static class InternalLog
|
||||
{
|
||||
public delegate void LogDelegate(params string[] msg);
|
||||
// вот к этому объекту подключайте методы для вывода логов
|
||||
public static event LogDelegate LogEvent;
|
||||
public static void Log(params string[] msg) => LogEvent?.Invoke(msg);
|
||||
}
|
||||
@ -12,7 +12,7 @@
|
||||
<Configuration>Release</Configuration>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<!--compilation properties-->
|
||||
<TargetFrameworks>netstandard2.0;net48;net6.0;net7.0</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||
<DebugType>embedded</DebugType>
|
||||
<!--language features-->
|
||||
<LangVersion>10</LangVersion>
|
||||
@ -35,7 +35,7 @@
|
||||
<ProjectReference Include="..\DTLib.Dtsod\DTLib.Dtsod.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
|
||||
<PackageReference Include="DTLib" Version="1.3.0" />
|
||||
<PackageReference Include="DTLib" Version="1.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--project files-->
|
||||
|
||||
Loading…
Reference in New Issue
Block a user