diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-12-28 23:30:23 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-12-28 23:30:23 +0200 |
| commit | 537212b4aa3419d75ce015e5aa3a455288dc430a (patch) | |
| tree | 60779db3e7c42611219a6f858db54aa6450c6eb0 /Software | |
| parent | 00de504d4d276063ec6b732cc95e476c89182df2 (diff) | |
| download | Tango-537212b4aa3419d75ce015e5aa3a455288dc430a.tar.gz Tango-537212b4aa3419d75ce015e5aa3a455288dc430a.zip | |
Implemented Azure Cloud Logger.
Implemented base class for global.asax
Diffstat (limited to 'Software')
| -rw-r--r-- | Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk | bin | 1445 -> 1530 bytes | |||
| -rw-r--r-- | Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk | bin | 1516 -> 1581 bytes | |||
| -rw-r--r-- | Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk | bin | 1444 -> 1529 bytes | |||
| -rw-r--r-- | Software/Visual_Studio/Build/Shortcuts/Stubs Execution GUI.lnk | bin | 1462 -> 1547 bytes | |||
| -rw-r--r-- | Software/Visual_Studio/Build/Shortcuts/Transport Router.lnk | bin | 1493 -> 1578 bytes | |||
| -rw-r--r-- | Software/Visual_Studio/Tango.Web/Logging/AzureCloudLogger.cs | 56 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.Web/Tango.Web.csproj | 2 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.Web/TangoWebApplication.cs | 42 | ||||
| -rw-r--r-- | Software/Visual_Studio/Web/Tango.MachineService/Global.asax.cs | 29 |
9 files changed, 103 insertions, 26 deletions
diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk Binary files differindex 7bbdf66b4..fd3743ce5 100644 --- a/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk +++ b/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk Binary files differindex 16360627d..a454f518f 100644 --- a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk +++ b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk diff --git a/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk b/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk Binary files differindex ab1bc5eed..ff739ffcb 100644 --- a/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk +++ b/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk diff --git a/Software/Visual_Studio/Build/Shortcuts/Stubs Execution GUI.lnk b/Software/Visual_Studio/Build/Shortcuts/Stubs Execution GUI.lnk Binary files differindex 5b8ad68a5..4115fb2ac 100644 --- a/Software/Visual_Studio/Build/Shortcuts/Stubs Execution GUI.lnk +++ b/Software/Visual_Studio/Build/Shortcuts/Stubs Execution GUI.lnk diff --git a/Software/Visual_Studio/Build/Shortcuts/Transport Router.lnk b/Software/Visual_Studio/Build/Shortcuts/Transport Router.lnk Binary files differindex febffabca..9294fa274 100644 --- a/Software/Visual_Studio/Build/Shortcuts/Transport Router.lnk +++ b/Software/Visual_Studio/Build/Shortcuts/Transport Router.lnk diff --git a/Software/Visual_Studio/Tango.Web/Logging/AzureCloudLogger.cs b/Software/Visual_Studio/Tango.Web/Logging/AzureCloudLogger.cs new file mode 100644 index 000000000..8cdc21d20 --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/Logging/AzureCloudLogger.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Logging; + +namespace Tango.Web.Logging +{ + /// <summary> + /// Represents an azure blob storage logger. + /// </summary> + /// <seealso cref="Tango.Logging.ILogger" /> + public class AzureCloudLogger : ILogger + { + /// <summary> + /// Initializes a new instance of the <see cref="AzureCloudLogger"/> class. + /// </summary> + public AzureCloudLogger() + { + Enabled = true; + } + + /// <summary> + /// Called when a new log is available. + /// </summary> + /// <param name="log">The log.</param> + public void OnLog(LogItemBase log) + { + switch (log.Category) + { + case LogCategory.Info: + Trace.TraceInformation(log.ToString()); + break; + case LogCategory.Warning: + Trace.TraceWarning(log.ToString()); + break; + case LogCategory.Error: + Trace.TraceError(log.ToString()); + break; + case LogCategory.Critical: + Trace.TraceError(log.ToString()); + break; + case LogCategory.Debug: + Trace.WriteLine(log.ToString()); + break; + } + } + + /// <summary> + /// Gets or sets a value indicating whether this <see cref="T:Tango.Logging.ILogger" /> is enabled. + /// </summary> + public bool Enabled { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.Web/Tango.Web.csproj b/Software/Visual_Studio/Tango.Web/Tango.Web.csproj index 70ac28e6e..0f04121d1 100644 --- a/Software/Visual_Studio/Tango.Web/Tango.Web.csproj +++ b/Software/Visual_Studio/Tango.Web/Tango.Web.csproj @@ -246,8 +246,10 @@ <Compile Include="ActiveDirectory\ActiveDirectoryManager.cs" /> <Compile Include="Authentication\TokensManager.cs" /> <Compile Include="DeploymentSlot.cs" /> + <Compile Include="Logging\AzureCloudLogger.cs" /> <Compile Include="Storage\ExtensionMethods.cs" /> <Compile Include="Storage\StorageManager.cs" /> + <Compile Include="TangoWebApplication.cs" /> <Compile Include="WebConfig.cs" /> <Compile Include="Controllers\JsonController.cs" /> <Compile Include="Formatters\JsonNetFormatter.cs" /> diff --git a/Software/Visual_Studio/Tango.Web/TangoWebApplication.cs b/Software/Visual_Studio/Tango.Web/TangoWebApplication.cs new file mode 100644 index 000000000..c9fea1678 --- /dev/null +++ b/Software/Visual_Studio/Tango.Web/TangoWebApplication.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Web; +using System.Web.Http; +using System.Web.Http.Filters; +using System.Web.Mvc; +using Tango.Logging; +using Tango.Web.Logging; + +namespace Tango.Web +{ + public class TangoWebApplication : HttpApplication + { + //Create filter + public class LogExceptionFilterAttribute : ExceptionFilterAttribute + { + public override void OnException(HttpActionExecutedContext context) + { + ErrorLogService.LogError(context.Exception); + } + } + + protected virtual void Application_Start() + { + LogManager.Default.RegisterLogger(new AzureCloudLogger()); + + GlobalConfiguration.Configuration.Filters.Add(new LogExceptionFilterAttribute()); + } + + //common service to be used for logging errors + public static class ErrorLogService + { + public static void LogError(Exception ex) + { + LogManager.Default.Log(ex, "Global Exception!"); + } + } + } +} diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Global.asax.cs b/Software/Visual_Studio/Web/Tango.MachineService/Global.asax.cs index ef698bb25..ef41ef3e7 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Global.asax.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Global.asax.cs @@ -9,40 +9,17 @@ using System.Web.Mvc; using System.Web.Optimization; using System.Web.Routing; using Tango.Logging; +using Tango.Web; namespace Tango.MachineService { - public class WebApiApplication : System.Web.HttpApplication + public class WebApiApplication : TangoWebApplication { - //Create filter - public class LogExceptionFilterAttribute : ExceptionFilterAttribute - { - public override void OnException(HttpActionExecutedContext context) - { - ErrorLogService.LogError(context.Exception); - } - } - - protected void Application_Start() + protected override void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); - - //LogManager.Default.RegisterLogger(new FileLogger()); - LogManager.Default.RegisterLogger(new VSOutputLogger("MachineService")); - - //register your filter with Web API pipeline - GlobalConfiguration.Configuration.Filters.Add(new LogExceptionFilterAttribute()); - } - - //common service to be used for logging errors - public static class ErrorLogService - { - public static void LogError(Exception ex) - { - LogManager.Default.Log(ex, "Global Exception!"); - } } } } |
