Пример #1
0
        public static void LogConsoleDebug(IFileAccessManager logFileManager, string sMsg, string sKeyword = "")
        {
            if (sKeyword != "")
            {
                sKeyword = "_" + sKeyword + "_ ";
            }

            string sLog = "TrajetTramLogger-- " + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss:fff") + ": " + sKeyword + sMsg;

            System.Diagnostics.Debug.WriteLine(sLog);
            MobileCenter_Helper.AddLog(sLog);
            logFileManager?.WriteToLogFile(sLog + "\n");
        }
Пример #2
0
        public static void ReportError(IFileAccessManager logFileManager, Exception e, [CallerFilePath] string sTitle = "", [CallerMemberName] string sDescription = "")
        {
            MobileCenter_Helper.AddAttachmentAndReportToMobileCenter(logFileManager, FormatErrorReporting(e, sTitle, sDescription).ToString());

            MobileCenter_Helper instance = MobileCenter_Helper.GetInstance();

            if (instance.m_sbLogs != null)
            {
                lock (locker)
                {
                    instance.m_sbLogs.Clear();
                    instance.m_sbLogs = null;
                }
            }
        }
Пример #3
0
        public static string SerializeObject <T>(IFileAccessManager logFileManager, T item, string sMoreInfoForExceptionThrowned = "")
        {
            string res = "";

            try
            {
                res = JsonConvert.SerializeObject(item);
            }
            catch (Exception e)
            {
                MobileCenter_Helper.ReportError(logFileManager, e, "SerializeObjectAsync<" + typeof(T).FullName + ">", "Error during JSON Serialization...\n\nitem = " + item.ToString() + "\n\nException.StackTrace = " + e.StackTrace + "\n\nMore Information... " + sMoreInfoForExceptionThrowned + "\n\nException.Message = " + e.Message);
            }

            return(res);
        }
Пример #4
0
        public static MobileCenter_Helper GetInstance()
        {
            if (m_instance == null)
            {
                lock (locker)
                {
                    if (m_instance == null)
                    {
                        m_instance = new MobileCenter_Helper();
                    }
                }
            }

            return(m_instance);
        }
Пример #5
0
        public static void ReportError(IFileAccessManager logFileManager, Exception e, StringBuilder dicInfos)
        {
            MobileCenter_Helper.AddAttachmentAndReportToMobileCenter(logFileManager, FormatErrorReporting(e, dicInfos).ToString());

            MobileCenter_Helper instance = MobileCenter_Helper.GetInstance();

            if (instance.m_sbLogs != null)
            {
                lock (locker)
                {
                    instance.m_sbLogs.Clear();
                    instance.m_sbLogs = null;
                }
            }
        }
Пример #6
0
        public static void AddLog(string sLog)
        {
            MobileCenter_Helper instance = MobileCenter_Helper.GetInstance();

            if (instance.m_sbLogs == null)
            {
                lock (locker)
                {
                    if (instance.m_sbLogs == null)
                    {
                        instance.m_sbLogs = new StringBuilder();
                    }
                }
            }

            lock (locker)
                instance.m_sbLogs.AppendLine(sLog);
        }
Пример #7
0
        public static T DeserializeObject <T>(IFileAccessManager logFileManager, string value, string sMoreInfoForExceptionThrowned)
        {
            T res = default(T);

            try
            {
                res = JsonConvert.DeserializeObject <T>(value);
            }
            catch (Exception e)
            {
                MobileCenter_Helper.ReportError(logFileManager, e,
                                                "DeserializeObjectAsync<" + typeof(T).FullName + ">",
                                                "Error during JSON Deserialization..." +
                                                "\n\ntext to deserialize = \"" + value +
                                                "\"\n\nMore Information... " + sMoreInfoForExceptionThrowned +
                                                "\n\nException.StackTrace = " + e.StackTrace +
                                                "\n\nException.Message = " + e.Message);
            }

            return(res);
        }
Пример #8
0
        private static StringBuilder FormatErrorReporting(Exception e, StringBuilder dicInfos, string sIncrement = "")
        {
            dicInfos.AppendLine(sIncrement + "Message = " + e.Message);
            dicInfos.AppendLine(sIncrement + "StackTrace = " + e.StackTrace);
            dicInfos.AppendLine(sIncrement + "Source = " + e.Source);
            dicInfos.AppendLine(sIncrement + "HResult = " + e.HResult.ToString());
            dicInfos.AppendLine(sIncrement + "Type = " + e.GetType().Name);

            if (e.InnerException != null)
            {
                dicInfos.AppendLine(sIncrement + "InnerException = " + e.InnerException.GetType().Name);

                dicInfos = FormatErrorReporting(e.InnerException, dicInfos, sIncrement + "_");
            }

            MobileCenter_Helper instance = MobileCenter_Helper.GetInstance();

            if (instance.m_sbLogs != null)
            {
                dicInfos.AppendLine(sIncrement + "TrajetTram Logs = " + instance.m_sbLogs.ToString());
            }

            return(dicInfos);
        }