Better logs for common ActionLog attribute paramters
This commit is contained in:
@@ -13,12 +13,12 @@ namespace MileageTraker.Web.Attributes
|
||||
var action = filterContext.RouteData.Values["action"].ToString();
|
||||
var username = filterContext.HttpContext.User.Identity.Name;
|
||||
var loggerName = string.Format("{0}Controller.{1}", controller, action);
|
||||
var @params = string.Join(", ", filterContext.ActionParameters.Select(i => i.Key + ": " + i.Value));
|
||||
var @params = string.Join(", ", filterContext.ActionParameters.Select(i => i.Key + ": {" + i.Value +"}"));
|
||||
|
||||
var hostAddress = "UserHostAddress: " + filterContext.HttpContext.Request.UserHostAddress;
|
||||
var hostAddress = filterContext.HttpContext.Request.UserHostAddress;
|
||||
|
||||
log4net.LogManager.GetLogger(loggerName)
|
||||
.InfoFormat("{0}, username: {1}, {2}", hostAddress, username, @params);
|
||||
.InfoFormat("UserHostAddress: {0}, username: {1}, params: {{{2}}}", hostAddress, username, @params);
|
||||
}
|
||||
base.OnActionExecuting(filterContext);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security;
|
||||
using System.Web;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using MileageTraker.Web.DAL;
|
||||
using MileageTraker.Web.Models;
|
||||
|
||||
namespace MileageTraker.Web.Attributes
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using MileageTraker.Web.Utility;
|
||||
|
||||
namespace MileageTraker.Web.Models
|
||||
{
|
||||
@@ -33,5 +34,10 @@ namespace MileageTraker.Web.Models
|
||||
{
|
||||
return new MileageLogTypeWrapper { Enum = c };
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Enum.GetDisplayName();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,5 +110,12 @@ namespace MileageTraker.Web.ViewModels.CreateLog
|
||||
if (result != null)
|
||||
yield return result;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(
|
||||
"vehicle: {0}, odo: {1}, type: {2}, city: {3}, gas: {4}, purpose: {5}, date: {6}",
|
||||
VehicleId, EndOdometer, LogType, CityName, GasPurchased, Purpose, Date.ToShortDateString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,5 +147,12 @@ namespace MileageTraker.Web.ViewModels.Log
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(
|
||||
"vehicle: {0}, odo: {1}, type: {2}, city: {3}, gas: {4}, purpose: {5}, date: {6}",
|
||||
VehicleId, EndOdometer, LogType, CityName, GasPurchased, Purpose, Date.ToShortDateString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,5 +6,10 @@ namespace MileageTraker.Web.ViewModels
|
||||
{
|
||||
public SelectList Available { get; set; }
|
||||
public int Selected { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Selected.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user