按照客户要求将excel导出文件保存为一个条码一条记录,名称为SN_结果_时间.xslx
This commit is contained in:
31
SLZ_4/FileLogger.cs
Normal file
31
SLZ_4/FileLogger.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SLZ_4
|
||||
{
|
||||
public enum LogLevel
|
||||
{
|
||||
DEBUG,
|
||||
INFO,
|
||||
WARNING,
|
||||
ERROR
|
||||
}
|
||||
class FileLogger
|
||||
{
|
||||
private static readonly string LogPath = Path.Combine(
|
||||
AppDomain.CurrentDomain.BaseDirectory,
|
||||
"logs",
|
||||
$"{DateTime.Now:yyyyMMdd}.log");
|
||||
|
||||
public static void Log(string message, LogLevel level = LogLevel.INFO)
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(LogPath));
|
||||
File.AppendAllText(LogPath,
|
||||
$"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] [{level}] {message}{Environment.NewLine}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user