mirror of
https://github.com/Ellpeck/ExtremelySimpleLogger.git
synced 2024-11-21 17:53:28 +01:00
more explicitly implement LogWriter
This commit is contained in:
parent
66842eec40
commit
096bc98a05
1 changed files with 222 additions and 2 deletions
|
@ -1,11 +1,11 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ExtremelySimpleLogger {
|
||||
/// <summary>
|
||||
/// Implementation of a <see cref="TextWriter"/> that writes to a <see cref="Logger"/>.
|
||||
/// The log writer constructs a message based on calls to <see cref="Write(string)"/> and its variations and then submits the message to the underlying <see cref="Logger"/> when <see cref="WriteLine()"/> or <see cref="Flush"/> is called. <see cref="WriteLine(string)"/> and its variations submit the message immediately.
|
||||
/// </summary>
|
||||
public class LogWriter : TextWriter {
|
||||
|
||||
|
@ -59,17 +59,237 @@ namespace ExtremelySimpleLogger {
|
|||
this.line.Append(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(char[] buffer) {
|
||||
lock (this.logger)
|
||||
this.line.Append(buffer);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(bool value) {
|
||||
lock (this.logger)
|
||||
this.line.Append(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(int value) {
|
||||
lock (this.logger)
|
||||
this.line.Append(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(uint value) {
|
||||
lock (this.logger)
|
||||
this.line.Append(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(long value) {
|
||||
lock (this.logger)
|
||||
this.line.Append(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(ulong value) {
|
||||
lock (this.logger)
|
||||
this.line.Append(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(float value) {
|
||||
lock (this.logger)
|
||||
this.line.Append(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(double value) {
|
||||
lock (this.logger)
|
||||
this.line.Append(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(decimal value) {
|
||||
lock (this.logger)
|
||||
this.line.Append(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(object value) {
|
||||
lock (this.logger)
|
||||
this.line.Append(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(string format, object arg0) {
|
||||
lock (this.logger)
|
||||
this.line.AppendFormat(this.FormatProvider, format, arg0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(string format, object arg0, object arg1) {
|
||||
lock (this.logger)
|
||||
this.line.AppendFormat(this.FormatProvider, format, arg0, arg1);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(string format, object arg0, object arg1, object arg2) {
|
||||
lock (this.logger)
|
||||
this.line.AppendFormat(this.FormatProvider, format, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(string format, params object[] arg) {
|
||||
lock (this.logger)
|
||||
this.line.AppendFormat(this.FormatProvider, format, arg);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(string value) {
|
||||
this.Write(value);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(char value) {
|
||||
this.Write(value);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(char[] buffer) {
|
||||
this.Write(buffer);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(char[] buffer, int index, int count) {
|
||||
this.Write(buffer, index, count);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(bool value) {
|
||||
this.Write(value);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(int value) {
|
||||
this.Write(value);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(uint value) {
|
||||
this.Write(value);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(long value) {
|
||||
this.Write(value);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(ulong value) {
|
||||
this.Write(value);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(float value) {
|
||||
this.Write(value);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(double value) {
|
||||
this.Write(value);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(decimal value) {
|
||||
this.Write(value);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(object value) {
|
||||
this.Write(value);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(string format, object arg0) {
|
||||
this.Write(format, arg0);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(string format, object arg0, object arg1) {
|
||||
this.Write(format, arg0, arg1);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(string format, object arg0, object arg1, object arg2) {
|
||||
this.Write(format, arg0, arg1, arg2);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine(string format, params object[] arg) {
|
||||
this.Write(format, arg);
|
||||
this.WriteLine();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void WriteLine() {
|
||||
this.Flush();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task WriteAsync(char value) {
|
||||
return Task.Run(() => this.Write(value));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task WriteAsync(string value) {
|
||||
return Task.Run(() => this.Write(value));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task WriteAsync(char[] buffer, int index, int count) {
|
||||
return Task.Run(() => this.Write(buffer, index, count));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task WriteLineAsync(char value) {
|
||||
return Task.Run(() => this.WriteLine(value));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task WriteLineAsync(string value) {
|
||||
return Task.Run(() => this.WriteLine(value));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task WriteLineAsync(char[] buffer, int index, int count) {
|
||||
return Task.Run(() => this.WriteLine(buffer, index, count));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task WriteLineAsync() {
|
||||
return Task.Run(this.WriteLine);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task FlushAsync() {
|
||||
return Task.Run(this.Flush);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Flush() {
|
||||
lock (this.logger) {
|
||||
|
|
Loading…
Reference in a new issue