You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
877 B
C#
29 lines
877 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace AutoUpdater
|
|
{
|
|
public class Logger
|
|
{
|
|
public static void Log(string message)
|
|
{
|
|
string logFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory , @"logs/");
|
|
if (!System.IO.Directory.Exists(logFile))
|
|
{
|
|
System.IO.Directory.CreateDirectory(logFile);
|
|
}
|
|
string filePath = logFile + "update.log";
|
|
using (StreamWriter sw = new StreamWriter(filePath , true , System.Text.Encoding.Default))
|
|
{
|
|
//确保线程安全
|
|
TextWriter tw = TextWriter.Synchronized(sw);
|
|
tw.Write(DateTime.Now.ToString("yyyy-MM-dd:HH:mm:ss")+"::"+message+"\r\n");
|
|
tw.Close();
|
|
}
|
|
}
|
|
}
|
|
}
|