Dreamine.Logging
1.0.2
Dreamine.Logging 프로젝트의 API와 구성 요소를 제공합니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
InMemoryLogStore.cs
이 파일의 문서화 페이지로 가기
1
using
System;
2
using
System.Collections.Generic;
3
using
System.Linq;
4
using
Dreamine.Logging.Interfaces
;
5
using
Dreamine.Logging.Models
;
6
7
namespace
Dreamine.Logging.Services
8
{
25
public
sealed
class
InMemoryLogStore
:
IDreamineLogStore
,
IDreamineLogSink
26
{
35
private
readonly
object
_syncRoot
=
new
();
44
private
readonly Queue<DreamineLogEntry>
_entries
;
53
private
readonly
int
_capacity
;
54
63
public
event
EventHandler<DreamineLogEntry>?
LogAdded
;
64
73
public
InMemoryLogStore
()
74
: this(1000)
75
{
76
}
77
94
public
InMemoryLogStore
(
int
capacity)
95
{
96
_capacity
= capacity <= 0 ? 1000 : capacity;
97
_entries
=
new
Queue<DreamineLogEntry>(
_capacity
);
98
}
99
116
public
IReadOnlyList<DreamineLogEntry>
GetEntries
()
117
{
118
lock (
_syncRoot
)
119
{
120
return
_entries
.ToArray();
121
}
122
}
123
148
public
void
Add
(
DreamineLogEntry
entry)
149
{
150
ArgumentNullException.ThrowIfNull(entry);
151
152
lock (
_syncRoot
)
153
{
154
_entries
.Enqueue(entry);
155
156
while
(
_entries
.Count >
_capacity
)
157
{
158
_entries
.Dequeue();
159
}
160
}
161
162
// Fire outside the lock to avoid reentrancy/deadlock if a handler
163
// calls back into the store.
164
LogAdded
?.Invoke(
this
, entry);
165
}
166
175
public
void
Clear
()
176
{
177
lock (
_syncRoot
)
178
{
179
_entries
.Clear();
180
}
181
}
182
207
public
void
Write
(
DreamineLogEntry
entry)
208
{
209
Add
(entry);
210
}
211
}
212
}
Dreamine.Logging.Interfaces
Definition
IDreamineLogFormatter.cs:3
Dreamine.Logging.Models
Definition
DreamineLogEntry.cs:3
Dreamine.Logging.Services
Definition
DreamineLogger.cs:5
Dreamine.Logging.Interfaces.IDreamineLogSink
Definition
IDreamineLogSink.cs:14
Dreamine.Logging.Interfaces.IDreamineLogStore
Definition
IDreamineLogStore.cs:14
Dreamine.Logging.Models.DreamineLogEntry
Definition
DreamineLogEntry.cs:14
Dreamine.Logging.Services.InMemoryLogStore._entries
readonly Queue< DreamineLogEntry > _entries
Definition
InMemoryLogStore.cs:44
Dreamine.Logging.Services.InMemoryLogStore.InMemoryLogStore
InMemoryLogStore()
Definition
InMemoryLogStore.cs:73
Dreamine.Logging.Services.InMemoryLogStore.Add
void Add(DreamineLogEntry entry)
Definition
InMemoryLogStore.cs:148
Dreamine.Logging.Services.InMemoryLogStore.Clear
void Clear()
Definition
InMemoryLogStore.cs:175
Dreamine.Logging.Services.InMemoryLogStore.GetEntries
IReadOnlyList< DreamineLogEntry > GetEntries()
Definition
InMemoryLogStore.cs:116
Dreamine.Logging.Services.InMemoryLogStore.Write
void Write(DreamineLogEntry entry)
Definition
InMemoryLogStore.cs:207
Dreamine.Logging.Services.InMemoryLogStore.LogAdded
EventHandler< DreamineLogEntry >? LogAdded
Definition
InMemoryLogStore.cs:63
Dreamine.Logging.Services.InMemoryLogStore._syncRoot
readonly object _syncRoot
Definition
InMemoryLogStore.cs:35
Dreamine.Logging.Services.InMemoryLogStore._capacity
readonly int _capacity
Definition
InMemoryLogStore.cs:53
Dreamine.Logging.Services.InMemoryLogStore.InMemoryLogStore
InMemoryLogStore(int capacity)
Definition
InMemoryLogStore.cs:94
Services
InMemoryLogStore.cs
다음에 의해 생성됨 :
1.17.0