time format fixed
This commit is contained in:
parent
fc1ec1401d
commit
762d53af19
@ -11,7 +11,7 @@ public class FileLogger : IDisposable
|
||||
}
|
||||
|
||||
public FileLogger(string dir, string programName)
|
||||
: this($"{dir}{Путь.Разд}{programName}_{DateTime.Now.ToString(MyTimeFormat.Instance)}.log") { }
|
||||
: this($"{dir}{Путь.Разд}{programName}_{DateTime.Now.ToString(MyTimeFormat.ForFileNames)}.log") { }
|
||||
|
||||
public string LogfileName { get; protected set; }
|
||||
public System.IO.FileStream LogfileStream { get; protected set; }
|
||||
@ -22,7 +22,7 @@ public class FileLogger : IDisposable
|
||||
{
|
||||
lock (LogfileStream)
|
||||
{
|
||||
LastLogMessageTime = DateTime.Now.ToString(MyTimeFormat.Instance);
|
||||
LastLogMessageTime = DateTime.Now.ToString(MyTimeFormat.ForText);
|
||||
LogfileStream.WriteByte('['.ToByte());
|
||||
LogfileStream.Write(LastLogMessageTime.ToBytes());
|
||||
LogfileStream.Write("]: ".ToBytes());
|
||||
|
||||
@ -13,6 +13,6 @@ public static class Tester
|
||||
operation();
|
||||
clock.Stop();
|
||||
double time=(double)(clock.ElapsedTicks)/Stopwatch.Frequency/repeats;
|
||||
Log("y",$"operation ","b",op_name,"y"," lasted ","b",time.ToString(MyTimeFormat.Instance),"y"," seconds");
|
||||
Log("y",$"operation ","b",op_name,"y"," lasted ","b",time.ToString(MyTimeFormat.ForText),"y"," seconds");
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,7 @@
|
||||
namespace DTLib;
|
||||
|
||||
public class MyTimeFormat : IFormatProvider
|
||||
public static class MyTimeFormat
|
||||
{
|
||||
public static MyTimeFormat Instance=new();
|
||||
public object GetFormat(Type formatType)
|
||||
{
|
||||
if(formatType==typeof(DateTime))
|
||||
return "yyyy-MM-dd_HH-mm-ss+zz";
|
||||
else throw new FormatException();
|
||||
}
|
||||
public const string ForFileNames="yyyy.MM.dd_HH-mm-ss_zz";
|
||||
public const string ForText="yyyy.MM.dd HH:mm:ss zz";
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user