
20 changed files with 608 additions and 632 deletions
-
4Apewer.Run/Batch.cs
-
4Apewer.Run/Process.cs
-
11Apewer/.editorconfig
-
2Apewer/Apewer.csproj
-
17Apewer/ILogable.cs
-
63Apewer/Internals/LogProvider.cs
-
44Apewer/KernelUtility.cs
-
43Apewer/LogItem.cs
-
305Apewer/Logger.cs
-
22Apewer/Models/StringPairs.cs
-
34Apewer/NetworkUtility.cs
-
66Apewer/Source/MySql.cs
-
83Apewer/Source/SqlServer.cs
-
29Apewer/SystemUtility.cs
-
154Apewer/Web/ApiInternals.cs
-
97Apewer/Web/ApiInvoker.cs
-
108Apewer/Web/ApiOptions.cs
-
67Apewer/Web/ApiResponse.cs
-
80Apewer/Web/WebUtility.cs
-
7Apewer/_ChangeLog.md
@ -1,11 +0,0 @@ |
|||
[*.cs] |
|||
|
|||
# CS3019: CLS 遵从性检查在此程序集外部不可见,因此不会执行它 |
|||
dotnet_diagnostic.CS3019.severity = none |
|||
|
|||
# CS0414: 字段已被赋值,但从未使用过它的值 |
|||
dotnet_diagnostic.CS0414.severity = none |
|||
|
|||
# CS0612: 已过时 |
|||
dotnet_diagnostic.CS0612.severity = none |
|||
|
@ -1,17 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Apewer |
|||
{ |
|||
|
|||
/// <summary>可记录日志。</summary>
|
|||
public interface ILogable |
|||
{ |
|||
|
|||
/// <summary>日志记录程序。</summary>
|
|||
Logger Logger { get; } |
|||
|
|||
} |
|||
|
|||
} |
@ -1,63 +0,0 @@ |
|||
using Apewer; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Threading; |
|||
|
|||
namespace Apewer.Internals |
|||
{ |
|||
|
|||
internal sealed class LogProvider |
|||
{ |
|||
|
|||
private static bool _running = false; |
|||
private static Thread _thread = null; |
|||
private static Queue<LogItem> _queue = new Queue<LogItem>(); |
|||
|
|||
private static void Listener() |
|||
{ |
|||
while (_running) |
|||
{ |
|||
var item = (LogItem)null; |
|||
lock (_queue) |
|||
{ |
|||
if (_queue.Count > 0) item = _queue.Dequeue(); |
|||
else |
|||
{ |
|||
_running = false; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if (item == null) continue; |
|||
if (item.Logger == null) continue; |
|||
try |
|||
{ |
|||
// item.Logger.Raise(item);
|
|||
} |
|||
catch { } |
|||
} |
|||
} |
|||
|
|||
public static void Queue(LogItem argItem) |
|||
{ |
|||
if (argItem == null) return; |
|||
lock (_queue) |
|||
{ |
|||
_queue.Enqueue(argItem); |
|||
if (_thread == null) |
|||
{ |
|||
_thread = new Thread(Listener); |
|||
_thread.IsBackground = false; |
|||
} |
|||
if (!_running) |
|||
{ |
|||
_running = true; |
|||
_thread.Start(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
@ -1,43 +0,0 @@ |
|||
using Apewer; |
|||
using Apewer.Internals; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Apewer |
|||
{ |
|||
|
|||
internal class LogItem |
|||
{ |
|||
|
|||
private Logger _logger; |
|||
private LogType _type; |
|||
|
|||
private Exception _exception = null; |
|||
private DateTime _triggered = DateTime.Now; |
|||
private string _content = null; |
|||
private string _target = null; |
|||
private object _custom = null; |
|||
|
|||
public DateTime Triggered { get { return _triggered; } } |
|||
|
|||
internal LogType Type { get { return _type; } } |
|||
|
|||
public Logger Logger { get { return _logger; } set { _logger = value; } } |
|||
|
|||
public Exception Exception { get { return _exception; } set { _exception = value; } } |
|||
|
|||
public string Content { get { return _content; } set { _content = value ?? ""; } } |
|||
|
|||
public string Target { get { return _target; } set { _target = value ?? ""; } } |
|||
|
|||
public object Custom { get { return _custom; } set { _custom = value; } } |
|||
|
|||
internal LogItem(LogType argType) |
|||
{ |
|||
_type = argType; |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue