Пример #1
0
        private static void WriteLog(string log, JLogType logType, JLogCategory logCat = JLogCategory.Common)
        {
            JLogMessage msg = new JLogMessage {
                LogType = logType, LogCategory = logCat, LogMessage = log
            };

            JLogThread.AddMessage(msg);
        }
Пример #2
0
        public void Write(JLogInfo logInfo, JLogType logType, Exception ex)
        {
            Level        level        = ConvertToLevel(logType);
            LoggingEvent loggingEvent = new LoggingEvent(ThisDeclaringType, Logger.Repository,
                                                         Logger.Name, level, logInfo.Message, ex);

            if (ex != null)
            {
                logInfo.Message = ex.Message + ex.StackTrace;
            }

            foreach (var property in logInfo.GetType().GetProperties())
            {
                loggingEvent.Properties[property.Name] = property.GetValue(logInfo, null);
            }
            Logger.Log(loggingEvent);
        }
        JAuthAttribute GetMenu(Type controllerType, JAuthType defaultAuthType, JLogType defaultLogType)
        {
            string controllerName = controllerType.Name.Substring(0, controllerType.Name.Length - 10);
            var    attr           = controllerType.GetCustomAttributes(false)
                                    .FirstOrDefault(co => co is JAuthAttribute) as JAuthAttribute;

            if (attr == null)
            {
                attr         = new JAuthAttribute(defaultAuthType, controllerName);
                attr.LogType = defaultLogType;
            }
            if (attr.Name.IsEmpty())
            {
                attr.Name = controllerName;
            }

            if (controllerType.Assembly == this.GetType().Assembly)
            {
                attr.AreaName = "/AppCenter";
            }
            return(attr);
        }
Пример #4
0
        static Level ConvertToLevel(JLogType logType)
        {
            switch (logType)
            {
            case JLogType.Info:
                return(Level.Info);

            case JLogType.Fatal:
                return(Level.Fatal);

            case JLogType.Error:
                return(Level.Error);

            case JLogType.Debug:
                return(Level.Debug);

            case JLogType.Warning:
                return(Level.Warn);

            default:
                return(Level.All);
            }
        }