A simple client program to test the library

A simple test harness for the logging library is given next. The program accepts a command-line parameter, which is the log target (NET | FILE | DB). We create the appropriate logging strategy classes using the factory method pattern.

    class Program 
    { 
      private static bool Table(LogStrategy ls) 
      { 
        int a = 10; 
        int b = 1; 
        while (b < 100) 
        { 
          ls.Log("Table", a.ToString() + " * " + 
          b.ToString(), "=" +(a * b).ToString()); 
          b++; 
        } 
        return true; 
      } 
      static void Main(string[] args) 
      { 
        if (args.Length != 1) 
        { 
          return;  
        }  
        string loggertype=args[0]; 
        LogStrategy lf = LoggerFactory.CreateLogger(loggertype); 
        Table(lf); 
      } 
    } 

The following UML diagram illustrates the key set of patterns in action for the logging API:

A simple client program to test the library

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.234.62