public void LogWritter(MessageLogger messageLogger)
 {
     using (var db = new LoggerMessage() )
     {
         db.InsertLog(messageLogger);
     }
 }
예제 #2
0
 public JobLoggerType(bool toFile, bool toConsole, bool toDatabase)
 {
     _toFile = toFile;
     _toConsole = toConsole;
     _toDatabase = toDatabase;
     _messageLogger = new MessageLogger {LoggerDate = DateTime.Now};
 }
예제 #3
0
 public void FileWritter(MessageLogger messageLogger, TextWriter w)
 {
     string newLine = Environment.NewLine;
     w.WriteLine("TYPE:         " + DescriptionMessageType((EnumLogger.KindOfLog)messageLogger.KinfOfLog) + newLine);
     w.WriteLine("DATETIME:     " + messageLogger.LoggerDate + newLine);
     w.WriteLine("DESCRIPTION:  " + messageLogger.Description + newLine);
     w.WriteLine("--------------------------------------------------------------------" + newLine);
 }
예제 #4
0
        public void LogWritter(MessageLogger messageLogger)
        {
            WritterFile.ValidPath();
            string pathFormat = WritterFile.FileFormatLog();

            using (StreamWriter w = File.AppendText(pathFormat))
            {
                WritterFile.FileWritter(messageLogger, w);
            }
        }
예제 #5
0
 public void LogWritter(MessageLogger messageLogger)
 {
     _messageLogger.Add(
         new MessageLogger
         {
             Description = messageLogger.Description,
             KinfOfLog = messageLogger.KinfOfLog,
             LoggerDate = messageLogger.LoggerDate
         }
         );
 }
        public void LogWritter(MessageLogger messageLogger)
        {
            string messageTypeName = DescriptionMessageType((EnumLogger.KindOfLog)messageLogger.KinfOfLog);
            StringBuilder sb = new StringBuilder();
            string newLine = Environment.NewLine;
            sb.Append("TYPE:         " + messageTypeName + newLine);
            sb.Append("DATETIME:     " + messageLogger.LoggerDate + newLine);
            sb.Append("DESCRIPTION:  " + messageLogger.Description + newLine);
            sb.Append("--------------------------------------------------------------------" + newLine);

            switch (messageLogger.KinfOfLog)
            {
                case (int)EnumLogger.KindOfLog.EError: Console.ForegroundColor = ConsoleColor.Red; break; ;
                case (int)EnumLogger.KindOfLog.WWarning: Console.ForegroundColor = ConsoleColor.Yellow; break;
                case (int)EnumLogger.KindOfLog.MMessage: Console.ForegroundColor = ConsoleColor.White; break;
            }

            Console.WriteLine(sb);
        }
예제 #7
0
        public void LogMessageAppeder(MessageLogger messageLogger)
        {
            Util.IsValidConfigurationToLog(_toFile, _toDatabase, _toConsole);
            Util.NoLog(messageLogger.Description);

            if (_toConsole) {
                LogMessageWritter(messageLogger, LoggerWritterConsole);
            }

            if (_toFile)
            {
                LogMessageWritter(messageLogger, LoggerWritterFile);
            }

            if (_toDatabase)
            {
                LogMessageWritter(messageLogger, LoggerWritterDatabase);
            }
        }
예제 #8
0
 public void InsertLog(MessageLogger messageLogger)
 {
     using (SqlConnection con = DbConnex.Connection)
     {
         con.Open();
         try
         {
             using (var command = new SqlCommand(
             "INSERT INTO TestLog VALUES(@MessageTestLog, @MessageType, @MessageDate)", con))
             {
                 command.Parameters.Add(new SqlParameter("MessageTestLog", messageLogger.Description));
                 command.Parameters.Add(new SqlParameter("MessageType", messageLogger.KinfOfLog));
                 command.Parameters.Add(new SqlParameter("MessageDate", messageLogger.LoggerDate));
                 command.ExecuteNonQuery();
             }
         }
         catch (Exception e)
         {
             Console.WriteLine("Couldn't insert." + e.Message);
         }
     }
 }
예제 #9
0
 private void LogMessageWritter(MessageLogger messageLogger, IJobLoggerWritter logger)
 {
     logger.LogWritter(messageLogger);
 }