I am using an external library which allows logging using StreamWriter - now I want to add some handling based on the content of the logging. As I want to avoid to loop through the log file, I would like to write a class which inherits from StreamWriter.
What is the best way to inherit from StreamWriter with as few re-implementations of methods/constructors?
I'm not sure of what you want to do exactly, but if you only want to inspect what is being written in the stream, you can do this:
public class CustomStreamWriter : StreamWriter
{
public CustomStreamWriter(Stream stream)
: base(stream)
{}
public override void Write(string value)
{
//Inspect the value and do something
base.Write(value);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With