Migración a percona
This commit is contained in:
85
ServicioGestionAsegasa/Logs.cs
Normal file
85
ServicioGestionAsegasa/Logs.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using bdAsegasa;
|
||||
using bdAsegasa.db;
|
||||
using Microsoft.VisualBasic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Serilog;
|
||||
|
||||
namespace Servicio_Gestion_Asegasa
|
||||
{
|
||||
public class Logs
|
||||
{
|
||||
private static object oBloqueoLog;
|
||||
//private static EventLog el;
|
||||
public static async Task AñadeLogAsync(tsUtilidades.Enumeraciones.TipoLog Tipo, string Mensaje, Exception e = null)
|
||||
{
|
||||
// ----------------------------------------------------------------------------------------------------
|
||||
// Descripción Sub: Gestión de logs de la aplicación
|
||||
// Fecha. Creacion: ???
|
||||
// Creada por: manmog
|
||||
// Ultima Modificacion: 24/11/2010
|
||||
//
|
||||
// Modificaciones:
|
||||
// ===============
|
||||
//if (oBloqueoLog == null) oBloqueoLog = new object();
|
||||
//lock (oBloqueoLog)
|
||||
//{
|
||||
try
|
||||
{
|
||||
if (e != null)
|
||||
{
|
||||
|
||||
string sStackTrace = "Tipo excepción: " + e.ToString() + Constants.vbCrLf;
|
||||
Exception exError = e;
|
||||
do
|
||||
{
|
||||
sStackTrace += exError.StackTrace + Constants.vbCrLf;
|
||||
exError = exError.InnerException;
|
||||
}
|
||||
while (!Information.IsNothing(exError));
|
||||
if (sStackTrace != "")
|
||||
Mensaje += Constants.vbCrLf + "|StackTrace: " + sStackTrace;
|
||||
}
|
||||
switch (Tipo)
|
||||
{
|
||||
case tsUtilidades.Enumeraciones.TipoLog.Fallo:
|
||||
Mensaje = "Error ServicioGestionAsegasa. " + " Enviado desde " + Environment.MachineName + ". Version:" + Assembly.GetEntryAssembly()?.GetName().Version + ". Mensaje: " + Mensaje;
|
||||
Log.Fatal(Mensaje);
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("Error en Servicio Gestion Asegasa", Mensaje, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
break;
|
||||
case tsUtilidades.Enumeraciones.TipoLog.Advertencia:
|
||||
Mensaje = "Advertencia ServicioGestionAsegasa. " + " Enviado desde " + Environment.MachineName + ". Version:" + Assembly.GetEntryAssembly()?.GetName().Version + ". " + Mensaje;
|
||||
Log.Warning(Mensaje);
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("Advertencia en Servicio Gestion Asegasa", Mensaje, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ADVERTENCIA);
|
||||
break;
|
||||
case tsUtilidades.Enumeraciones.TipoLog.InicioServicio:
|
||||
Mensaje = "Inicio ServicioGestionAsegasa. " + " Enviado desde " + Environment.MachineName + ". Version:" + Assembly.GetEntryAssembly()?.GetName().Version + ". Mensaje: " + Mensaje;
|
||||
Log.Information(Mensaje);
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("Inicio Servicio Gestion Asegasa", Mensaje, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.INFO);
|
||||
break;
|
||||
case tsUtilidades.Enumeraciones.TipoLog.FinServicio:
|
||||
Mensaje = "Finalización ServicioGestionAsegasa. " + " Enviado desde " + Environment.MachineName + ". Version:" + Assembly.GetEntryAssembly()?.GetName().Version + ". Mensaje: " + Mensaje;
|
||||
Log.Information(Mensaje);
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("Finalización Servicio Gestion Asegasa", Mensaje, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.INFO);
|
||||
break;
|
||||
default:
|
||||
Mensaje = Tipo.ToString() + " ServicioGestionAsegasa. " + " Enviado desde " + Environment.MachineName + ". Version:" + Assembly.GetEntryAssembly()?.GetName().Version + ". " + Mensaje;
|
||||
Log.Information(Mensaje);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (e != null)
|
||||
Mensaje += " --- " + e.StackTrace;
|
||||
|
||||
Log.Fatal(Mensaje + " ---" + ex.Message + " --- " + ex.StackTrace);
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user