public static ILogWriter GetLogWriter <T>(object parameters) where T : ILogWriter
        {
            if (instance == null)
            {
                instance = new LogWriterFactory();
            }

            ConsoleLogWriter  ConsoleLog  = new ConsoleLogWriter();
            FileLogWriter     FileLog     = new FileLogWriter((string)parameters);
            MultipleLogWriter MultipleLog = new MultipleLogWriter(new List <ILogWriter> {
                ConsoleLog, FileLog
            });

            return(MultipleLog);
        }
        public static ILogWriter GetLogWriter <T>(object parameters) where T : ILogWriter
        {
            if (instance == null)
            {
                instance = new LogWriterFactory();
            }

            ConsoleLogWriter  ConsoleLog  = new ConsoleLogWriter();
            FileLogWriter     FileLog     = new FileLogWriter();
            MultipleLogWriter MultipleLog = new MultipleLogWriter(new List <ILogWriter> {
                ConsoleLog, FileLog
            });

            MultipleLog.LogError("Error");
            MultipleLog.LogInfo("Info");
            MultipleLog.LogInfo("Warning");
            return(MultipleLog);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            //FileLogWriter fileLogWriter1 = new FileLogWriter(@"C:\Users\zalimbekova\test1_log.txt");
            //LogWriterFactory fileLogWriter1 = LogWriterFactory.GetInstance();
            using var fileLogWriter1 = (FileLogWriter)LogWriterFactory.GetLogWriter <FileLogWriter>(@"C:\Users\zalimbekova\test1_log.txt");

            var consoleWriter1 = (ConsoleLogWriter)LogWriterFactory.GetLogWriter <ConsoleLogWriter>(null);
            var multi          = (MultipleLogWriter)LogWriterFactory.GetLogWriter <MultipleLogWriter>(new[] { (ILogWriter)fileLogWriter1, (ILogWriter)consoleWriter1 });

            ///ConsoleLogWriter consoleWriter1 = new ConsoleLogWriter();

            //using var logwriter = new MultipleLogWriter(new[] { (ILogWriter)fileLogWriter1, (ILogWriter)consoleWriter1 });
            multi.LogInfo("starting the system");
            multi.LogWarning("the disc is almost full");
            multi.LogError("the system has crashed");

            //LogWriterFactory factory = new LogWriterFactory();
            //var log1 = factory.GetLogWriter<MultipleLogWriter<ILogWriter>>(ILogWriter);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            var test = LogWriterFactory.GetLogWriter <ILogWriter>(@"C:\Users\jimac\Desktop\log.txt");

            test.LogError("error!");


            //var clw = new ConsoleLogWriter();
            ////clw.LogInfo("Test Information message");

            //var flw = new FileLogWriter(@"C:\Users\jimac\Desktop\log.txt");
            ////flw.LogInfo("Test information message");

            //var mlw = new MultipleLogWriter(new List<ILogWriter> { clw, flw });
            //clw.LogInfo("Test info mess");
            //flw.LogInfo("Test info mess");
            //mlw.LogInfo("testsdasd");
            //mlw.Dispose();
            //flw.Dispose();
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            var factory = LogWriterFactory.GetInstance();

            var consoleLogWriter = factory.GetLogWriter <ConsoleLogWriter>(parameters: null);
            var fileLogWriter    = factory.GetLogWriter <FileLogWriter>(parameters: @"C:\Users\jimac\Desktop\log.txt");
            var multiLogWriter   = factory.GetLogWriter <FileLogWriter>(parameters: new[] { consoleLogWriter, fileLogWriter });

            multiLogWriter.LogError(message: "Error!");


            //var clw = new ConsoleLogWriter();
            ////clw.LogInfo("Test Information message");

            //var flw = new FileLogWriter(@"C:\Users\jimac\Desktop\log.txt");
            ////flw.LogInfo("Test information message");

            //var mlw = new MultipleLogWriter(new List<ILogWriter> { clw, flw });
            //clw.LogInfo("Test info mess");
            //flw.LogInfo("Test info mess");
            //mlw.LogInfo("testsdasd");
            //mlw.Dispose();
            //flw.Dispose();
        }