Skip to content

Commit

Permalink
add ILogComponent wrapping File.WriteAllText
Browse files Browse the repository at this point in the history
  • Loading branch information
dninemfive committed Jul 20, 2024
1 parent 4f56cf5 commit 11f89c1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions logging/Log.Components.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ public static class Components
public static ILogComponent Console
=> new DelegateLogComponent(System.Console.Write, System.Console.WriteLine);
/// <summary>
/// An <see cref="ILogComponent"/> which opens, writes to, and saves a given file on each call.
/// </summary>
/// <param name="filePath">The path of the file to write to.</param>
public static ILogComponent WriteTextTo(string filePath)
=> new DelegateLogComponent((obj) => File.WriteAllText(filePath, $"{obj}"),
(obj) => File.WriteAllText(filePath, $"{obj}\n"));
/// <summary>
/// An <see cref="ILogComponent"/> which writes to the specified stream.
/// </summary>
/// <param name="stream">The stream to write to.</param>
Expand Down

0 comments on commit 11f89c1

Please sign in to comment.