Esempio n. 1
0
        public override string ToString()
        {
            if (Type == LogTypeEnum.CUSTOM)
            {
                return(CustomName);
            }

            return(Type.ToString());
        }
Esempio n. 2
0
        private string GetLogDiv(string message, LogTypeEnum logType)
        {
            return
                ($@"
                            'type': '{logType.ToString().ToLower()}',
                            'time': '{DateTime.Now.TimeOfDay}',
                            'message': '{message}'
                        }}

                   ");
        }
Esempio n. 3
0
        public LogAuditoria(string identifier, string message, string detail, LogSourceEnum source, LogTypeEnum type)
        {
            Id = Guid.NewGuid();

            Identifier = identifier;
            Message    = message;
            Detail     = detail;
            Source     = source.ToString();
            Type       = type.ToString();
            Data       = DateTime.Now;
        }
Esempio n. 4
0
        private string GetLogFileName(LogTypeEnum logType)
        {
            switch (logType)
            {
            case LogTypeEnum.SelectOne:
                throw new NotSupportedException("A log type must be selected.");

            case LogTypeEnum.Application:
                return(logType.ToString());

            case LogTypeEnum.Security:
                return(logType.ToString());

            case LogTypeEnum.Setup:
                return(logType.ToString());

            case LogTypeEnum.System:
                return(logType.ToString());
            }

            return(LogTypeEnum.Application.ToString());
        }
Esempio n. 5
0
        public void Log(LogTypeEnum logType, string message, string properties)
        {
            string logFile = GetLogFileName();

            EnsureFileExists(logFile);

            var el = (XmlElement)_LogXml.DocumentElement.AppendChild(_LogXml.CreateElement("log"));

            el.SetAttribute("datecreated", CurrentDatetime);
            el.SetAttribute("logType", logType.ToString());
            el.AppendChild(_LogXml.CreateElement("message")).InnerText    = message;
            el.AppendChild(_LogXml.CreateElement("properties")).InnerText = properties;

            _LogXml.Save(logFile);
        }
Esempio n. 6
0
        static string SaveLog(LogTypeEnum logTypeEnum, string logMessage)
        {
            if (HttpContext.Current.Items.Contains("GeneralLog"))
            {
                object controller = HttpContext.Current.Request.RequestContext.RouteData.Values["controller"];
                object action     = HttpContext.Current.Request.RequestContext.RouteData.Values["action"];

                GeneralLog generalLog      = HttpContext.Current.Items["GeneralLog"] as GeneralLog;
                GeneralLog errorGeneralLog = Mapper.Map <GeneralLog, GeneralLog>(generalLog);
                errorGeneralLog.Id                = Guid.NewGuid().ToString();
                errorGeneralLog.LogType           = logTypeEnum.ToString();
                errorGeneralLog.RequestTraceId    = generalLog.Id;
                errorGeneralLog.RequestAction     = action == null ? "" : action.ToString();
                errorGeneralLog.RequestController = controller == null ? "" : controller.ToString();
                errorGeneralLog.CreateTime        = errorGeneralLog.CreateTime == default(DateTime) ? DateTime.Now : errorGeneralLog.CreateTime;
                return(errorGeneralLog.Id);
            }
            return(null);
        }
Esempio n. 7
0
        protected override void Log(object logData, LogTypeEnum logType) {

            string path = Path.GetFullPath(this.ConfigurationUtility.LogPath);
            string fullPath = Path.GetFullPath(path + "WhereIsMyChangeLog.txt");

            if (Directory.Exists(path) == false) {

                Directory.CreateDirectory(path);
            }

            if (File.Exists(fullPath) == false) {

                File.Create(fullPath).Dispose();
            }

            string serializedObject = Dlp.Framework.Serializer.JsonSerialize(logData);

            string content = string.Format("{0} - {1} - {2}{3}", DateTime.UtcNow, logType.ToString(), serializedObject, Environment.NewLine);

            File.AppendAllText(fullPath, content);
        }
Esempio n. 8
0
            public static LogAuditoria NewLogAuditoriaFull(string identifier, string message, string detail, LogSourceEnum source, LogTypeEnum type, string user, string hostname, string url, string controller, string method, int statusCode, string cookies, string serverVariables)
            {
                var logAudit = new LogAuditoria()
                {
                    Id   = Guid.NewGuid(),
                    Data = DateTime.Now,

                    Identifier      = identifier,
                    Message         = message,
                    Detail          = detail,
                    Source          = source.ToString(),
                    Type            = type.ToString(),
                    User            = user,
                    Hostname        = hostname,
                    Url             = url,
                    Controller      = controller,
                    Method          = method,
                    StatusCode      = statusCode,
                    Cookies         = cookies,
                    ServerVariables = serverVariables
                };

                return(logAudit);
            }
Esempio n. 9
0
 public Log4NetWriter(LogTypeEnum logType)
 {
     _log4Net = log4net.LogManager.GetLogger(logType.ToString());
 }
 /// <summary>
 /// 根据LogContent写日志
 /// </summary>
 /// <param name="content"></param>
 public static void Log(LogContent content, LogTypeEnum logType)
 {
     Log(content.ToString(), logType.ToString());
 }
 /// <summary>
 /// 写日志
 /// </summary>
 /// <param name="msg"></param>
 public static void Log(string msg, LogTypeEnum logType)
 {
     Log(msg, logType.ToString());
 }
Esempio n. 12
0
        public static void Log(LogTypeEnum type, string msg)
        {
            if (!Directory.Exists(LOG_DIR))
            {
                Directory.CreateDirectory(LOG_DIR);
            }

            File.AppendAllText(Path.Combine(LOG_DIR, LOG_NAME), DateTime.Now.ToString() + " " + type.ToString() + " " + msg + Environment.NewLine);
        }