Example #1
0
        private static void LogExceptionInThread(object threadInfoObject)
        {
            var        infoLogCommand = (ThreadInfoLogCommand)threadInfoObject;
            MethodBase methodBase     = infoLogCommand.StackFrame.GetMethod();
            string     methodBody     = GetMethodBody(methodBase);

            string exceptionText = infoLogCommand.Exception == null ? string.Empty : infoLogCommand.Exception.Message + infoLogCommand.Exception.InnerException;

            if (IsSendToNetwork)
            {
                var queryCommand = new QueryCommand
                {
                    CommandText      = exceptionText,
                    Created          = DateTime.Now.ToString(),
                    MethodName       = methodBase.Name,
                    MethodBody       = methodBody,
                    ClassName        = methodBase.DeclaringType.FullName,
                    QueryMiliseconds = infoLogCommand.ElapsedMilliseconds,
                    ResultRowsCount  = infoLogCommand.ResultRowsCount,
                    StackTrace       = infoLogCommand.StackTraceSnippet
                };
                CommandSender.SendQueryCommand(queryCommand);
            }

            Nlogger.AddLogMessage(string.Format("\r\n Exception {0}; \r\n Method Name {1}; \r\n Class Name {2}; \r\n Elapsed Miliseconds {3}", exceptionText, methodBase.Name, methodBase.DeclaringType.FullName, infoLogCommand.ElapsedMilliseconds));
        }
Example #2
0
        private static void WriteMessageInThread(object threadInfoObject)
        {
            var infoLogCommand = (ThreadInfoLogCommand)threadInfoObject;

            MethodBase methodBase = infoLogCommand.StackFrame.GetMethod();
            string     methodBody = GetMethodBody(methodBase);

            if (IsSendToNetwork)
            {
                var queryCommand = new QueryCommand
                {
                    CommandText      = infoLogCommand.Message,
                    Created          = DateTime.Now.ToString(),
                    MethodName       = methodBase.Name,
                    MethodBody       = methodBody,
                    ClassName        = methodBase.DeclaringType.FullName,
                    QueryMiliseconds = 0,
                    ResultRowsCount  = 0,
                    StackTrace       = infoLogCommand.StackTraceSnippet
                };
                CommandSender.SendQueryCommand(queryCommand);
            }

            Nlogger.AddLogMessage(string.Format("\r\n Message: {0};\r\n Method Name: {1};\r\n Class Name: {2}", infoLogCommand.Message, methodBase.Name, methodBase.DeclaringType.FullName));
        }
Example #3
0
        private static void LogInThread(object threadInfoObject)
        {
            var infoLogCommand = (ThreadInfoLogCommand)threadInfoObject;

            MethodBase methodBase = infoLogCommand.StackFrame.GetMethod();
            string     methodBody = GetMethodBody(methodBase);

            SqlLogRecord sqlLogRecord = new SqlLogRecord
            {
                CommandText      = infoLogCommand.CommandText,
                Created          = DateTime.Now.ToString(),
                MethodName       = methodBase.Name,
                MethodBody       = methodBody,
                ClassName        = methodBase.DeclaringType.FullName,
                QueryMiliseconds = infoLogCommand.ElapsedMilliseconds,
                ResultRowsCount  = infoLogCommand.ResultRowsCount,
                StackTrace       = infoLogCommand.StackTraceSnippet
            };

            if (IsSendToNetwork)
            {
                var queryCommand = new QueryCommand
                {
                    CommandText      = infoLogCommand.CommandText,
                    Created          = DateTime.Now.ToString(),
                    MethodName       = methodBase.Name,
                    MethodBody       = methodBody,
                    ClassName        = methodBase.DeclaringType.FullName,
                    QueryMiliseconds = infoLogCommand.ElapsedMilliseconds,
                    ResultRowsCount  = infoLogCommand.ResultRowsCount,
                    StackTrace       = infoLogCommand.StackTraceSnippet
                };
                CommandSender.SendQueryCommand(queryCommand);
            }
            Nlogger.AddLogMessage(sqlLogRecord);
            Nlogger.AddLogMessage(string.Format("\r\n Command text:{0}; \r\n  Method Name:{1}; \r\n Class Name:{2}; \r\n Elapsed Miliseconds:{3}", infoLogCommand.CommandText, methodBase.Name, methodBase.DeclaringType.FullName, infoLogCommand.ElapsedMilliseconds));
        }
Example #4
0
 public static void SetLogDelegate(Action <string> action)
 {
     Nlogger.SetLogDelegate(action);
 }
Example #5
0
 public static void SetLogDelegate(Action <SqlLogRecord> action)
 {
     Nlogger.SetSqlLogRecordDelegate(action);
 }