Beispiel #1
0
        static void Main(string[] args)
        {
            var conslog  = new ConsoleLogWriter();
            var textlog  = new FileLogWriter("log.txt");
            var multi    = new ILogWriter[] { conslog, textlog };   //save instances in a variable
            var multilog = new MultipleLogWriter(multi);            //create a new instance and pass as an argument a variable that stores a collection of instances

            multilog.LogInfo("Some information about the program"); //new event to record
            multilog.LogError("Some information about the error in the program");
            multilog.LogInfo("Warning about possible problems in the program");
            multilog.LogError("Some information about the error in the program");
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var logInFile    = new FileLogWriter();
            var logInConsole = new ConsoleLogWriter();

            var multipleLogWriter = new MultipleLogWriter(logInFile, logInConsole);

            multipleLogWriter.LogError("ErrorMessage");
            multipleLogWriter.LogInfo("InfoMessage");
            multipleLogWriter.LogWarning("WarningMessage");

            Console.ReadKey();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            var logInFile    = FileLogWriter.GetInstance("C:/StudioLog/Log.log");
            var logInConsole = ConsoleLogWriter.GetInstance();

            var multipleLogWriter = new MultipleLogWriter(logInFile, logInConsole);

            multipleLogWriter.LogError("ErrorMessage");
            multipleLogWriter.LogInfo("InfoMessage");
            multipleLogWriter.LogWarning("WarningMessage");

            Console.ReadKey();
        }
Beispiel #4
0
        static void Main()
        {
            var cons = new ConsoleLogWriter();

            cons.LogWarning("ВОт ЭТО ОШИБКа");
            cons.LogError("Err");
            cons.LogInfo("ИНфо");
            var file = new FileLogWriter();

            file.LogWarning("ВОт ЭТО ОШИБКа");
            file.LogError("Err");
            file.LogInfo("ИНфо");
            var mult = new MultipleLogWriter(cons, file);

            mult.LogInfo("конлсь инфо");
            mult.LogWarning("конлсь варнинг");
            mult.LogError("конлсь ерор");
            Console.ReadKey();
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            var fileLogWriter = new FileLogWriter();

            fileLogWriter.LogError("FileLogWriter says there is an error!");

            var consoleLogWriter = new ConsoleLogWriter();

            consoleLogWriter.LogWarning("ConsoleLogWriter says there is a warning!");

            var multipleLogWriter = new MultipleLogWriter(new List <AbstractLogWriter>
            {
                new FileLogWriter(),
                new ConsoleLogWriter(),
                new MultipleLogWriter(new List <AbstractLogWriter>
                {
                    new ConsoleLogWriter(),
                    new ConsoleLogWriter()
                })
            });

            multipleLogWriter.LogInfo("MultipleLogWriter created");
        }