예제 #1
0
        private static void LogWrite(LogLevel level,
                                     string msg, string logClass, string subClass, string pars,
                                     string results, Exception ex)
        {
            LogMessageInfo info = new LogMessageInfo();

            if (pars != null)              // && pars.Count > 0)
            {
                info.ParamDesc = pars;     // GetMessage(pars);
            }
            if (results != null)           //&& results.Count > 0)
            {
                info.ResultDesc = results; // GetMessage(results);
            }
            info.Details = msg;

            info.CallDesc = GetInvokeDesc();
            info.Level    = level;
            if (ex != null)
            {
                info.ErrorMsg = string.Format("msg:{0};stack:{1}", ex.Message, ex.StackTrace);
            }
            if (!string.IsNullOrEmpty(logClass))
            {
                info.LogClass = logClass;
            }
            if (!string.IsNullOrEmpty(subClass))
            {
                info.SubClass = subClass;
            }
            AsyWriteLog(level, info);
        }
예제 #2
0
        //private void WriteLog(RunTimeLoger rtl)
        //{
        //    //if (log.IsInfoEnabled)
        //    //{
        //    //    log.Info(rtl.loginfo,
        //    //}

        //}
//LogOutStyle outStyle,
        /// <summary>
        /// 写日志统一入口
        /// </summary>
        /// <param name="logHelper"></param>
        /// <param name="level"></param>
        /// <param name="info"></param>
        /// <param name="ex"></param>
        private static void AsyWriteLog(LogLevel level, LogMessageInfo info)//, Exception ex)
        {
            //lock (curLock)
            //{
            LogMessageHelper logHelper     = new LogMessageHelper(level);//LogOutStyle.FileLog);
            WriteLogDelegate logDeletegate = logHelper.WriteLog;

            logDeletegate.BeginInvoke(level, info, null, null);    // OnMethodWriteLog, null);
            //}
        }
예제 #3
0
        private void WriteLog(LogLevel level, LogMessageInfo info)//,Exception ex)
        {
            lock (curLock)
            {
                switch (level)
                {
                //case LogLevel.FATAL:
                //    if (log.IsFatalEnabled)
                //    {
                //        log.Fatal(info);
                //    }
                //    break;
                case LogLevel.ERROR:
                    if (log.IsErrorEnabled)
                    {
                        log.Error(info);
                    }
                    break;

                //case LogLevel.WARN:
                //    if (log.IsWarnEnabled)
                //    {
                //        log.Warn(info);
                //    }
                //    break;
                case LogLevel.INFO:
                    if (log.IsInfoEnabled)
                    {
                        log.Info(info);
                    }
                    break;

                case LogLevel.DEBUG:
                    if (log.IsDebugEnabled)
                    {
                        log.Debug(info);
                    }
                    break;
                }
            }
        }