Esempio n. 1
0
 public void Log(CSVLog log)
 {
     lock (this)
     {
         var line = String.Join(SEPARATOR, log.GetType().GetProperties().Select(t => t.GetValue(log)));
         WriteLine(line);
     }
 }
Esempio n. 2
0
        public void LogAction(System.Web.Http.Filters.HttpActionExecutedContext actionExecutedContext, ActionLogger actionLogger)
        {
            var log = new CSVLog
            {
                Action      = actionExecutedContext.ActionContext.ActionDescriptor.ActionName,
                Controller  = actionExecutedContext.ActionContext.ControllerContext.ControllerDescriptor.ControllerName,
                Date        = DateTime.UtcNow,
                Description = actionLogger.getDescription(actionExecutedContext),
                IP          = IPUtils.GetClientIp(actionExecutedContext.Request)
            };

            var user = Common.UserUtils.GetUser(actionExecutedContext.Request);

            if (user != null)
            {
                log.UserEmail = user.Email;
                log.Username  = user.UserName;
            }

            Log(log);
        }