VLog.cs
989 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
public class VLog
{
ILog log;
string Prefix="";
public VLog(string prefix="",string logname= "VStore") {
Prefix = prefix;
log = LogManager.GetLogger(logname);
}
string lastinfo = "";
public void Info(string txt) {
if (String.Compare(lastinfo, txt, StringComparison.Ordinal) == 0)
return;
if (Prefix != "")
txt =$"[{Prefix}] "+ txt;
log.Info(txt);
}
string lasterr = "";
public void Error(string txt)
{
if (String.Compare(lasterr, txt, StringComparison.Ordinal) == 0)
return;
if (Prefix != "")
txt = $"[{Prefix}] " + txt;
log.Error(txt);
}
}
}