Example #1
0
        static void Main(string[] args)
        {
            LogConfiguration oConfig = new LogConfiguration(true,true,true,true,true,true);

            JobLogger oJobLogger = new JobLogger(oConfig);

            LogMessage msg = new LogMessage("Test", LogMessage.typeMessage.msg);

            oJobLogger.LogMessage(msg);
        }
Example #2
0
        private void decorarMensaje(LogMessage msg)
        {
            msg.message = DateTime.Now.ToShortDateString() + msg.message;

            switch (msg.type)
            {
                case LogMessage.typeMessage.msg: msg.message = "MESSAGE:" + msg.message;
                    break;
                case LogMessage.typeMessage.error: msg.message = "ERROR:" + msg.message;
                    break;
                case LogMessage.typeMessage.warning: msg.message = "WARNING:" + msg.message;
                    break;
                default:
                    break;
            }
        }
Example #3
0
        public void LogMessage(LogMessage msg)
        {
            if (msg.message == null || msg.message.Length == 0)
            {
                return;
            }

            if ((msg.type == Logger.LogMessage.typeMessage.msg && config._logMessage)||
               (msg.type == Logger.LogMessage.typeMessage.error && config._logError)||
               (msg.type == Logger.LogMessage.typeMessage.warning && config._logWarning))
            {
                foreach (ILoggeable dependency in logDestination)
                {
                    dependency.Log(msg);
                }
            }
        }
Example #4
0
 private void setConsoleColor(LogMessage.typeMessage typeMsg)
 {
     switch (typeMsg)
     {
      case LogMessage.typeMessage.msg:
         Console.ForegroundColor = ConsoleColor.White;
      break;
      case LogMessage.typeMessage.error:
         Console.ForegroundColor = ConsoleColor.Red;
      break;
      case LogMessage.typeMessage.warning:
         Console.ForegroundColor = ConsoleColor.Yellow;
      break;
      default:
         Console.ForegroundColor = ConsoleColor.Gray;
      break;
     }
 }
Example #5
0
        public void Log(LogMessage msg)
        {
            string datosConexion = getDatosConexion();
            using (SqlConnection connection = new SqlConnection(datosConexion))
            {
                try
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand("Insert into Log Values('" + msg.message + "', " +((int)msg.type).ToString() + ")");
                    command.ExecuteNonQuery();

                    command = null;
                    connection.Close();
                }
                catch (SqlException ex)
                {

                    throw new Exception("Error SQL:"+ex.Message);
                }

            }
        }
Example #6
0
 public void Log(LogMessage msg)
 {
     setConsoleColor(msg.type);
     Console.WriteLine(DateTime.Now.ToShortDateString() +":"+ msg.message);
 }
Example #7
0
 public void Log(LogMessage msg)
 {
     string pathLog = getDirectorioLogs();
     decorarMensaje(msg);
     escribirMensaje(msg.message,pathLog);
 }