Dreamine.Logging
1.0.2
Dreamine.Logging 프로젝트의 API와 구성 요소를 제공합니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
CompositeLogSink.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.Sinks
8
{
25
public
sealed
class
CompositeLogSink
:
IDreamineLogSink
, IDisposable
26
{
35
private
readonly IReadOnlyList<IDreamineLogSink>
_sinks
;
44
private
bool
_disposed
;
45
78
public
CompositeLogSink
(IEnumerable<IDreamineLogSink> sinks)
79
{
80
ArgumentNullException.ThrowIfNull(sinks);
81
82
_sinks
= sinks.ToArray();
83
84
if
(
_sinks
.Count == 0)
85
{
86
throw
new
ArgumentException(
"At least one log sink is required."
, nameof(sinks));
87
}
88
}
89
114
public
void
Write
(
DreamineLogEntry
entry)
115
{
116
ArgumentNullException.ThrowIfNull(entry);
117
118
if
(
_disposed
)
119
{
120
return
;
121
}
122
123
foreach
(var sink
in
_sinks
)
124
{
125
try
126
{
127
sink.Write(entry);
128
}
129
catch
130
{
131
// Logging failure must not terminate the application.
132
}
133
}
134
}
135
144
public
void
Dispose
()
145
{
146
if
(
_disposed
)
147
{
148
return
;
149
}
150
151
_disposed
=
true
;
152
153
foreach
(var sink
in
_sinks
)
154
{
155
if
(sink is IDisposable disposable)
156
{
157
try
158
{
159
disposable.Dispose();
160
}
161
catch
162
{
163
// Logging dispose failure must not terminate the application.
164
}
165
}
166
}
167
}
168
}
169
}
Dreamine.Logging.Interfaces
Definition
IDreamineLogFormatter.cs:3
Dreamine.Logging.Models
Definition
DreamineLogEntry.cs:3
Dreamine.Logging.Sinks
Definition
AsyncQueueSink.cs:10
Dreamine.Logging.Interfaces.IDreamineLogSink
Definition
IDreamineLogSink.cs:14
Dreamine.Logging.Models.DreamineLogEntry
Definition
DreamineLogEntry.cs:14
Dreamine.Logging.Sinks.CompositeLogSink._sinks
readonly IReadOnlyList< IDreamineLogSink > _sinks
Definition
CompositeLogSink.cs:35
Dreamine.Logging.Sinks.CompositeLogSink.Write
void Write(DreamineLogEntry entry)
Definition
CompositeLogSink.cs:114
Dreamine.Logging.Sinks.CompositeLogSink._disposed
bool _disposed
Definition
CompositeLogSink.cs:44
Dreamine.Logging.Sinks.CompositeLogSink.Dispose
void Dispose()
Definition
CompositeLogSink.cs:144
Dreamine.Logging.Sinks.CompositeLogSink.CompositeLogSink
CompositeLogSink(IEnumerable< IDreamineLogSink > sinks)
Definition
CompositeLogSink.cs:78
Sinks
CompositeLogSink.cs
다음에 의해 생성됨 :
1.17.0