public void LogWritter(MessageLogger messageLogger) { using (var db = new LoggerMessage() ) { db.InsertLog(messageLogger); } }
public JobLoggerType(bool toFile, bool toConsole, bool toDatabase) { _toFile = toFile; _toConsole = toConsole; _toDatabase = toDatabase; _messageLogger = new MessageLogger {LoggerDate = DateTime.Now}; }
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); }
public void LogWritter(MessageLogger messageLogger) { WritterFile.ValidPath(); string pathFormat = WritterFile.FileFormatLog(); using (StreamWriter w = File.AppendText(pathFormat)) { WritterFile.FileWritter(messageLogger, w); } }
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); }
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); } }
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); } } }
private void LogMessageWritter(MessageLogger messageLogger, IJobLoggerWritter logger) { logger.LogWritter(messageLogger); }