Files
LeafWeb/Web/Attributes/ActionLogAttribute.cs
T
poprhythm 10cd2986cf Organize Piscal Service items
Add nlog, PiscalQueueManager

	modified:   Core.Tests/Remote/PiscalSshClientTests.cs
	modified:   Core/DAL/DataService.cs
	modified:   Core/Remote/IPiscalClient.cs
	modified:   Core/Remote/PiscalSshClient.cs
	new file:   Web/Attributes/ActionLogAttribute.cs
	modified:   Web/Controllers/ControllerBase.cs
	modified:   Web/Controllers/LeafInputController.cs
	modified:   Web/Controllers/LeafOutputController.cs
	new file:   Web/NLog.config
	new file:   Web/NLog.xsd
	new file:   Web/Services/PiscalQueueManager.cs
	modified:   Web/Services/PiscalService.cs
	modified:   Web/Startup.cs
	modified:   Web/Web.csproj
	modified:   Web/packages.config

Ignore logs

Organize piscal queue manager

	modified:   Core/Entities/LeafInputFile.cs
	modified:   Web/Controllers/LeafInputController.cs
	renamed:    Web/Startup.cs -> Web/HangfireStartup.cs
	modified:   Web/Services/PiscalQueueManager.cs
	modified:   Web/Web.csproj

cleanup usings in leafinputcontroller
2016-03-01 07:35:58 -05:00

27 lines
915 B
C#

using System.Linq;
using System.Web.Mvc;
using NLog;
namespace LeafWeb.Web.Attributes
{
public class ActionLogAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (filterContext != null)
{
var controller = filterContext.RouteData.Values["controller"].ToString();
var action = filterContext.RouteData.Values["action"].ToString();
var username = filterContext.HttpContext.User.Identity.Name;
var loggerName = $"{controller}Controller.{action}";
var @params = string.Join(", ", filterContext.ActionParameters.Select(i => $"{i.Key}: {{{i.Value}}}"));
var hostAddress = filterContext.HttpContext.Request.UserHostAddress;
LogManager.GetLogger(loggerName)
.Info("UserHostAddress: {0}, username: {1}, params: {{{2}}}", hostAddress, username, @params);
}
base.OnActionExecuting(filterContext);
}
}
}