The first class that I always implement in a new project is Log.
Why?

Because always is needed!!

Let’s start by a simple LogToFile class. It has to care about creating the file if it doesn’t exist or set the current time and date in any appoinment.

Support several message severity will be a plus: Error, Warning, Info and Debug (in decreasing severity)

It must be very easy to use, I don’t want to create an objecto previously, so it must have static method like this.

Log.LogError(message) o Log.LogInfo(message)

So, make a singleton Logger seems a good idea. Lets create a Log static instance, that the static method will use (or create if it is null)

Then we can generalice the class in order to support a general stream because we want to send our errors to a socket or a zipped file or to a printer….

The singleton pattern will help us in order to use the especialiced classes:
If I create a socket Log, the instance will be the the socketLog type and every Log.LogError will use the especiliced method.

The main porpose of this blog is write about the development of a c# framework.

In the way  we’ll learn a lot and have fun!!

 

Sorry about my bad English.

Tags