Fix eccezioni logging

This commit is contained in:
Samuele E. Locatelli
2020-02-22 09:02:47 +01:00
parent 9dcaff8721
commit d489d25554
5 changed files with 162 additions and 51 deletions
+7 -3
View File
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using SteamWare.Logger;
using System;
using System.Collections.Generic;
using System.Configuration;
@@ -399,7 +400,9 @@ namespace IOB_MAN
result.Wait();
}
catch (Exception exc)
{ }
{
Logging.Instance.Error($"MainTimer_Tick {exc}");
}
}
MainTimer.Start();
}
@@ -415,7 +418,9 @@ namespace IOB_MAN
result.Wait();
}
catch (Exception exc)
{ }
{
Logging.Instance.Error($"forceCheckTimer_Tick {exc}");
}
}
checkWatchdog();
// riavvio i timer x sicurezza...
@@ -997,7 +1002,6 @@ namespace IOB_MAN
private void apriChildSel()
{
int pid = -1;
// SOLO SE selezionato in dgv...
if (dgvManagedItems.SelectedRows.Count > 0)
{
+1
View File
@@ -106,6 +106,7 @@
<Compile Include="Enums.cs" />
<Compile Include="fileMover.cs" />
<Compile Include="IniFile.cs" />
<Compile Include="Logging.cs" />
<Compile Include="Objects.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RedisMan.cs" />
+40
View File
@@ -0,0 +1,40 @@
using NLog;
using NLog.Config;
using NLog.Targets;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace IOB_UT
{/// <summary>
/// Classe helper x LOG basata su NLog
/// </summary>
public static class Logging
{
/// <summary>
/// S
/// </summary>
public static NLog.Logger Instance { get; private set; }
static Logging()
{
#if DEBUG
// Setup the logging view for Sentinel - http://sentinel.codeplex.com
var sentinalTarget = new NLogViewerTarget()
{
Name = "sentinal",
Address = "udp://127.0.0.1:9999",
IncludeNLogData = false
};
var sentinalRule = new LoggingRule("*", LogLevel.Trace, sentinalTarget);
LogManager.Configuration.AddTarget("sentinal", sentinalTarget);
LogManager.Configuration.LoggingRules.Add(sentinalRule);
#endif
LogManager.ReconfigExistingLoggers();
Instance = LogManager.GetCurrentClassLogger();
}
}
}
+83 -48
View File
@@ -28,8 +28,10 @@ namespace IOB_UT
sb.AppendLine($"Status: {connRedis.GetStatus()}");
answ = sb.ToString();
}
catch
{ }
catch (Exception exc)
{
Logging.Instance.Error($"getRedisInfoData {exc}");
}
return answ;
}
/// <summary>
@@ -76,8 +78,10 @@ namespace IOB_UT
{
answ = string.Format($"{baseUtils.CRS("appName")}:{keyName}");
}
catch
{ }
catch(Exception exc)
{
Logging.Instance.Error($"redHash {exc}");
}
return answ;
}
/// <summary>
@@ -92,7 +96,10 @@ namespace IOB_UT
{
answ = JsonConvert.SerializeObject(origVal);
}
catch { }
catch (Exception exc)
{
Logging.Instance.Error($"serializeVal {exc}");
}
return answ;
}
/// <summary>
@@ -107,7 +114,10 @@ namespace IOB_UT
{
answ = JsonConvert.DeserializeObject(serVal);
}
catch { }
catch (Exception exc)
{
Logging.Instance.Error($"deserializeVal {exc}");
}
return answ;
}
/// <summary>
@@ -176,7 +186,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
//logger.lg.scriviLog(string.Format("{0}", exc), tipoLog.EXCEPTION);
Logging.Instance.Error($"redServInfo {exc}");
}
return answ;
}
@@ -194,7 +204,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
//logger.lg.scriviLog(string.Format("Errore in getRSV:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
Logging.Instance.Info($"getRSV {exc}");
}
return answ;
}
@@ -214,7 +224,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
//logger.lg.scriviLog(string.Format("Errore in setRSV:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
Logging.Instance.Error($"setRSV {exc}");
}
return answ;
}
@@ -237,7 +247,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
//logger.lg.scriviLog(string.Format("Errore in setRSV:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
Logging.Instance.Error($"setRSV {exc}");
}
return answ;
}
@@ -255,7 +265,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
//logger.lg.scriviLog(string.Format("Errore in setRCI:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
Logging.Instance.Error($"setRCntI {exc}");
}
return answ;
}
@@ -273,7 +283,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
//logger.lg.scriviLog(string.Format("Errore in setRCD:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
Logging.Instance.Error($"setRCntD {exc}");
}
return answ;
}
@@ -293,7 +303,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
//logger.lg.scriviLog(string.Format("Errore in getRSV:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
Logging.Instance.Error($"getRCnt {exc}");
}
return answInt;
}
@@ -311,7 +321,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
//logger.lg.scriviLog(string.Format("Errore in resetRCnt:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
Logging.Instance.Error($"resetRCnt {exc}");
}
return answ;
}
@@ -329,7 +339,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
//logger.lg.scriviLog(string.Format("Errore in getRKeys:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
Logging.Instance.Error($"getRKeys {exc}");
}
return answ;
}
@@ -348,7 +358,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
//logger.lg.scriviLog(string.Format("Errore in setRKeys:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
Logging.Instance.Error($"setRKeys {exc}");
}
return answ;
}
@@ -367,7 +377,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
//logger.lg.scriviLog(string.Format("Errore in redKeyPresent per la key {2}:{0}{1}", Environment.NewLine, exc, key), tipoLog.EXCEPTION);
Logging.Instance.Error($"redKeyPresent {exc}");
}
return answ;
}
@@ -384,8 +394,10 @@ namespace IOB_UT
RedisKey chiave = key;
answ = redKeyPresent(chiave);
}
catch
{ }
catch (Exception exc)
{
Logging.Instance.Error($"redKeyPresentSz {exc}");
}
return answ;
}
/// <summary>
@@ -403,7 +415,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
//logger.lg.scriviLog(string.Format("Errore in redHashPresent per la key {2}{0}{1}", Environment.NewLine, exc, key), tipoLog.EXCEPTION);
Logging.Instance.Error($"redHashPresent {exc}");
}
return answ;
}
@@ -420,8 +432,10 @@ namespace IOB_UT
RedisKey chiave = key;
answ = redHashPresent(chiave);
}
catch
{ }
catch (Exception exc)
{
Logging.Instance.Error($"redHashPresentSz {exc}");
}
return answ;
}
/// <summary>
@@ -445,8 +459,10 @@ namespace IOB_UT
i++;
}
}
catch
{ }
catch (Exception exc)
{
Logging.Instance.Error($"redGetHash {exc}");
}
return answ;
}
/// <summary>
@@ -467,8 +483,10 @@ namespace IOB_UT
answ.Add(item.Name, item.Value);
}
}
catch
{ }
catch (Exception exc)
{
Logging.Instance.Error($"redGetHashDict {exc}");
}
return answ;
}
/// <summary>
@@ -488,8 +506,10 @@ namespace IOB_UT
RedisValue valOut = cache.HashGet(chiave, campo);
answ = valOut.ToString();
}
catch
{ }
catch (Exception exc)
{
Logging.Instance.Error($"redGetHashField {exc}");
}
return answ;
}
/// <summary>
@@ -515,8 +535,10 @@ namespace IOB_UT
cache.HashSet(chiave, valori);
answ = true;
}
catch
{ }
catch (Exception exc)
{
Logging.Instance.Error($"redSaveHash {exc}");
}
return answ;
}
/// <summary>
@@ -542,8 +564,10 @@ namespace IOB_UT
cache.HashSet(chiave, valori);
answ = true;
}
catch
{ }
catch (Exception exc)
{
Logging.Instance.Error($"redSaveHashDict {exc}");
}
return answ;
}
@@ -573,8 +597,10 @@ namespace IOB_UT
cache.HashSet(chiave, valori);
answ = true;
}
catch
{ }
catch (Exception exc)
{
Logging.Instance.Error($"redSaveHashList {exc}");
}
}
return answ;
}
@@ -597,10 +623,11 @@ namespace IOB_UT
{
cache.KeyExpire(chiave, DateTime.Now.AddSeconds(expireSeconds));
}
//answ = true;
}
catch
{ }
catch (Exception exc)
{
Logging.Instance.Error($"redSaveHash {exc}");
}
return answ;
}
/// <summary>
@@ -624,8 +651,10 @@ namespace IOB_UT
}
//answ = true;
}
catch
{ }
catch (Exception exc)
{
Logging.Instance.Error($"redSaveHashDict {exc}");
}
return answ;
}
/// <summary>
@@ -643,8 +672,10 @@ namespace IOB_UT
cache.KeyDelete(chiave);
answ = true;
}
catch
{ }
catch (Exception exc)
{
Logging.Instance.Error($"redDelKey {exc}");
}
return answ;
}
/// <summary>
@@ -673,7 +704,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
//logger.lg.scriviLog(string.Format("{0}", exc), tipoLog.EXCEPTION);
Logging.Instance.Error($"redFlushKey {exc}");
}
return answ;
}
@@ -701,7 +732,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
//logger.lg.scriviLog(string.Format("{0}", exc), tipoLog.EXCEPTION);
Logging.Instance.Error($"redCountKey {exc}");
}
return answ;
}
@@ -722,8 +753,10 @@ namespace IOB_UT
answ += server.DatabaseSize();
}
}
catch
{ }
catch (Exception exc)
{
Logging.Instance.Error($"numRecRedis {exc}");
}
return answ;
}
}
@@ -757,7 +790,7 @@ namespace IOB_UT
}
catch (Exception exc)
{
//logger.lg.scriviLog(string.Format("{0}", exc), tipoLog.EXCEPTION);
Logging.Instance.Error($"redGetCounterByKey 01 {exc}");
}
// ora recupero valori!
var valori = getRKeys(chiavi);
@@ -771,8 +804,10 @@ namespace IOB_UT
answ.Add(new KeyValuePair<string, int>(chiavi[i], currVal));
}
}
catch
{ }
catch (Exception exc)
{
Logging.Instance.Error($"redGetCounterByKey 02 {exc}");
}
// se richiesto riordino...
switch (orderBy)
{
+31
View File
@@ -6,3 +6,34 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Gli identificatori non devono contenere caratteri di sottolineatura", Justification = "<In sospeso>", Scope = "namespace", Target = "~N:IOB_WIN")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specificare IFormatProvider", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_WIN.IobSiemensSaet.processWhatchDog")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1303:Non passare valori letterali come parametri localizzati", Justification = "<In sospeso>", Scope = "member", Target = "~M:IOB_WIN.IobSiemensSaet.#ctor(IOB_WIN.AdapterForm,IOB_WIN.IobConfiguration)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.lastUrl")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlAddPzCount")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlAlive")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlForceSplit")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlGetCurrODL")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlGetParams2Write")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlGetPzCount")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlGetPzCountRec")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlGetTask2Exe")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlIdleTime")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlInizioOdlIob")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlIobEnabled")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlReboot")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlRemTask2Exe")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlSaveAllParams")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlSaveMemMap")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlSetM2IOB")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlSetOptVal")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlSetPzCount")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlSetPzCountMAC")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobGeneric.urlUpdateWriteParams")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.IobMTC.urlSaveDataItems")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.MainForm.updateUrl")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.MainForm.urlAlive")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.MainForm.urlDownloadFile")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.MainForm.urlDownloadFileCloud")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.MainForm.urlIob2call")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.MainForm.urlReboot")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.MainForm.urlUploadFile")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Le proprietà Uri non devono essere stringhe", Justification = "<In sospeso>", Scope = "member", Target = "~P:IOB_WIN.MainForm.urlUploadFileCloud")]