diff --git a/DTLib.Dtsod/Dependencies/linux/x64/kerep.so b/DTLib.Dtsod/Dependencies/linux/x64/kerep.so
deleted file mode 100644
index c1abf1c..0000000
Binary files a/DTLib.Dtsod/Dependencies/linux/x64/kerep.so and /dev/null differ
diff --git a/DTLib.Dtsod/Dependencies/windows/x64/kerep.dll b/DTLib.Dtsod/Dependencies/windows/x64/kerep.dll
index 2286c23..f896d99 100644
Binary files a/DTLib.Dtsod/Dependencies/windows/x64/kerep.dll and b/DTLib.Dtsod/Dependencies/windows/x64/kerep.dll differ
diff --git a/DTLib.Dtsod/Dependencies/windows/x86/kerep.dll b/DTLib.Dtsod/Dependencies/windows/x86/kerep.dll
deleted file mode 100644
index 109371d..0000000
Binary files a/DTLib.Dtsod/Dependencies/windows/x86/kerep.dll and /dev/null differ
diff --git a/DTLib.Dtsod/V24/KerepTypes/KVPair.cs b/DTLib.Dtsod/V24/KerepTypes/KVPair.cs
index ce2670d..9ad84b5 100644
--- a/DTLib.Dtsod/V24/KerepTypes/KVPair.cs
+++ b/DTLib.Dtsod/V24/KerepTypes/KVPair.cs
@@ -21,6 +21,7 @@ public struct KVPair
public override string ToString()
{
+ throw new NotImplementedException("Marshal.PtrToStringUTF8 can't get non-ascii chars?");
return $"{{{Marshal.PtrToStringUTF8(key)}, {value}}}";
}
}
\ No newline at end of file
diff --git a/DTLib.Tests/DTLib.Tests.csproj b/DTLib.Tests/DTLib.Tests.csproj
index 3e5e4e1..55ed785 100644
--- a/DTLib.Tests/DTLib.Tests.csproj
+++ b/DTLib.Tests/DTLib.Tests.csproj
@@ -20,7 +20,7 @@
-
+
@@ -28,8 +28,12 @@
-
- Always
-
+
+
+
+
+
+
+
diff --git a/DTLib.Tests/Dtsod/TestPInvoke.cs b/DTLib.Tests/Dtsod/TestPInvoke.cs
index 211429f..d8f2804 100644
--- a/DTLib.Tests/Dtsod/TestPInvoke.cs
+++ b/DTLib.Tests/Dtsod/TestPInvoke.cs
@@ -19,7 +19,7 @@ public static class TestPInvoke
public static void TestPrintf()
{
- Info.Log("c", "---------[TestPInvoke/Printf]---------");
+ Info.Log("c", "---------[TestPInvoke/Printf]---------", "b", "");
pinvoke_print("ъъ~ 中文");
Info.Log("g", "test completed");
}
@@ -29,7 +29,7 @@ public static class TestPInvoke
public static unsafe void TestMarshalling()
{
- Info.Log("c", "---------[TestAutoarr/Print]----------");
+ Info.Log("c", "---------[TestAutoarr/TestMarshalling]----------");
string msg = "ъъ~ 中文";
test_marshalling(msg, out KVPair* kptr);
KVPair k = *kptr;
diff --git a/DTLib.Tests/Program.cs b/DTLib.Tests/Program.cs
index bd1bfd1..de48fb1 100644
--- a/DTLib.Tests/Program.cs
+++ b/DTLib.Tests/Program.cs
@@ -17,7 +17,7 @@ namespace DTLib.Tests;
public static class Program
{
- public static readonly ConsoleLogger Info = new();
+ public static readonly ConsoleLogger Info = new("logs", "DTLib.Tests");
public static void Main()
{
PublicLog.LogEvent += Info.Log;
diff --git a/DTLib/Logging/BaseLogger.cs b/DTLib/Logging/BaseLogger.cs
deleted file mode 100644
index 354b2d2..0000000
--- a/DTLib/Logging/BaseLogger.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System.IO;
-using File = DTLib.Filesystem.File;
-
-namespace DTLib.Logging;
-
-public abstract class BaseLogger : IDisposable
-{
- public BaseLogger() { }
- public BaseLogger(string logfile)
- {
- WriteToFile=true;
- LogfileName = logfile;
- LogfileStream = File.OpenWrite(logfile);
- }
-
- public BaseLogger(string dir, string programName)
- : this($"{dir}\\{programName}_{DateTime.Now}.log".Replace(':', '-').Replace(' ', '_')) { }
-
- public string LogfileName { get; protected set; }
- public FileStream LogfileStream { get; protected set; }
-
- protected readonly object _statelocker = new();
-
- private bool _isEnabled=true;
- public bool IsEnabled
- {
- get { lock (_statelocker) return _isEnabled; }
- set { lock (_statelocker) _isEnabled = value; }
- }
-
- private bool _writeToFile;
- public bool WriteToFile
- {
- get { lock (_statelocker) return _writeToFile; }
- set { lock (_statelocker) _writeToFile = value; }
- }
-
- public abstract void Log(params string[] msg);
-
- public virtual void Dispose()
- {
- LogfileStream?.Flush();
- LogfileStream?.Close();
- }
-
- ~BaseLogger() => Dispose();
-}
diff --git a/DTLib/Logging/ConsoleLogger.cs b/DTLib/Logging/ConsoleLogger.cs
index 74c8118..35933ac 100644
--- a/DTLib/Logging/ConsoleLogger.cs
+++ b/DTLib/Logging/ConsoleLogger.cs
@@ -1,11 +1,8 @@
-using System.Globalization;
-
-namespace DTLib.Logging;
+namespace DTLib.Logging;
// вывод лога в консоль и файл
-public class ConsoleLogger : BaseLogger
+public class ConsoleLogger : FileLogger
{
- public ConsoleLogger() : base() {}
public ConsoleLogger(string logfile) : base(logfile){}
public ConsoleLogger(string dir, string programName) : base(dir, programName) {}
@@ -14,9 +11,11 @@ public class ConsoleLogger : BaseLogger
public override void Log(params string[] msg)
{
- if (!IsEnabled) return;
+ // write to file
+ base.Log(msg);
+ // append timestamp
var strb = new StringBuilder();
- strb.Append('[').Append(DateTime.Now.ToString(CultureInfo.InvariantCulture)).Append("]: ");
+ strb.Append('[').Append(LastLogMessageTime).Append("]: ");
int index = msg.Length == 1 ? 0 : 1;
strb.Append(msg[index]);
msg[index] = strb.ToString();
@@ -26,21 +25,5 @@ public class ConsoleLogger : BaseLogger
ColoredConsole.Write(msg);
Console.WriteLine();
}
- // write to file
- if (!WriteToFile) return;
- if (msg.Length == 1)
- lock (LogfileStream)
- {
- LogfileStream.Write(msg[0].ToBytes());
- LogfileStream.WriteByte('\n'.ToByte());
- }
- else
- {
- for (ushort i = 3; i < msg.Length; i+=2)
- strb.Append(msg[i]);
- strb.Append('\n');
- lock (LogfileStream)
- LogfileStream.Write(strb.ToString().ToBytes());
- }
}
}
diff --git a/DTLib/Logging/FileLogger.cs b/DTLib/Logging/FileLogger.cs
new file mode 100644
index 0000000..0cc3905
--- /dev/null
+++ b/DTLib/Logging/FileLogger.cs
@@ -0,0 +1,49 @@
+using System.Globalization;
+
+namespace DTLib.Logging;
+
+public class FileLogger : IDisposable
+{
+ public FileLogger(string logfile)
+ {
+ LogfileName = logfile;
+ LogfileStream = File.OpenAppend(logfile);
+ }
+
+ public FileLogger(string dir, string programName)
+ : this($"{dir}\\{programName}_{DateTime.Now}.log".Replace(':', '-').Replace(' ', '_')) { }
+
+ public string LogfileName { get; protected set; }
+ public System.IO.FileStream LogfileStream { get; protected set; }
+ protected string LastLogMessageTime;
+
+
+ public virtual void Log(params string[] msg)
+ {
+ lock (LogfileStream)
+ {
+ LastLogMessageTime = DateTime.Now.ToString(CultureInfo.InvariantCulture);
+ LogfileStream.WriteByte('['.ToByte());
+ LogfileStream.Write(LastLogMessageTime.ToBytes());
+ LogfileStream.Write("]: ".ToBytes());
+ if (msg.Length == 1)
+ LogfileStream.Write(msg[0].ToBytes());
+ else
+ {
+ var strb = new StringBuilder();
+ for (ushort i = 1; i < msg.Length; i += 2)
+ strb.Append(msg[i]);
+ LogfileStream.Write(strb.ToString().ToBytes());
+ }
+ LogfileStream.WriteByte('\n'.ToByte());
+ }
+ }
+
+ public virtual void Dispose()
+ {
+ LogfileStream?.Flush();
+ LogfileStream?.Close();
+ }
+
+ ~FileLogger() => Dispose();
+}
diff --git a/build.sh b/build.sh
index a478f5f..55390ab 100644
--- a/build.sh
+++ b/build.sh
@@ -3,4 +3,4 @@ dotnet build -c Release
dotnet build -c Debug
rm -rf bin
mkdir bin
-cp -rv DTLib.*/bin/* bin/
+cp -rv DTLib.Tests/bin/* bin/
diff --git a/test.sh b/test.sh
new file mode 100644
index 0000000..d4b456f
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,4 @@
+printf "
+first line
+second line
+"