From 5da5ebe3bc182afdb49bc043fe2255b4d08e222f Mon Sep 17 00:00:00 2001
From: ShiningRush <277040271@qq.com>
Date: Sat, 6 Jan 2018 18:59:42 +0800
Subject: [PATCH] fixed bug
---
.../ServiceAntModule.cs | 2 +-
.../ServiceAntInstaller.cs | 2 +-
src/ServiceAnt/IServiceBus.cs | 29 ++++++++++++++++++-
src/ServiceAnt/InProcessServiceBus.cs | 8 ++---
...ServiceAnt.IocInstaller.Castle.Test.csproj | 2 +-
5 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/src/ServiceAnt.IocInstaller.Autofac/ServiceAntModule.cs b/src/ServiceAnt.IocInstaller.Autofac/ServiceAntModule.cs
index 184d700..335cdca 100644
--- a/src/ServiceAnt.IocInstaller.Autofac/ServiceAntModule.cs
+++ b/src/ServiceAnt.IocInstaller.Autofac/ServiceAntModule.cs
@@ -21,7 +21,7 @@ public class ServiceAntModule : Module
///
/// Constructor
///
- /// the assemblies which containg handler, thos will be register to container
+ /// the assemblies which containg handler, those will be register to container
public ServiceAntModule(params System.Reflection.Assembly[] handlerAssemblies)
{
_handlerAssemblies = handlerAssemblies;
diff --git a/src/ServiceAnt.IocInstaller.Castle/ServiceAntInstaller.cs b/src/ServiceAnt.IocInstaller.Castle/ServiceAntInstaller.cs
index 25aa493..68725ff 100644
--- a/src/ServiceAnt.IocInstaller.Castle/ServiceAntInstaller.cs
+++ b/src/ServiceAnt.IocInstaller.Castle/ServiceAntInstaller.cs
@@ -26,7 +26,7 @@ public class ServiceAntInstaller : IWindsorInstaller
///
/// Constructor
///
- /// the assemblies which containg handler, thos will be register to container
+ /// the assemblies which containg handler, those will be register to container
public ServiceAntInstaller(params Assembly[] handlerAssemblies)
{
_handlerAssemblies = handlerAssemblies;
diff --git a/src/ServiceAnt/IServiceBus.cs b/src/ServiceAnt/IServiceBus.cs
index 6ba5c65..4a58729 100644
--- a/src/ServiceAnt/IServiceBus.cs
+++ b/src/ServiceAnt/IServiceBus.cs
@@ -6,6 +6,33 @@
namespace ServiceAnt
{
+ ///
+ /// BusMessageLevel
+ ///
+ public enum LogLevel
+ {
+ ///
+ /// Debug
+ ///
+ DEBUG,
+ ///
+ /// INFO
+ ///
+ INFO,
+ ///
+ /// Error
+ ///
+ ERROR
+ }
+
+ ///
+ /// This delegate used to handle bus message
+ ///
+ /// message level
+ /// message
+ /// if happended exception, it will return it
+ public delegate void LogBusMessage(LogLevel msgLevel, string message, Exception ex);
+
///
/// It used to publish event or send a request
///
@@ -14,7 +41,7 @@ public interface IServiceBus : IAddSubscription, IAddRequestHandler
///
/// Use to log message of bus
///
- event Action OnLogBusMessage;
+ event LogBusMessage OnLogBusMessage;
///
/// Publish a event
diff --git a/src/ServiceAnt/InProcessServiceBus.cs b/src/ServiceAnt/InProcessServiceBus.cs
index bf8e6f5..eb15d39 100644
--- a/src/ServiceAnt/InProcessServiceBus.cs
+++ b/src/ServiceAnt/InProcessServiceBus.cs
@@ -22,7 +22,7 @@ public class InProcessServiceBus : IServiceBus
///
/// Use to log message of bus
///
- public event Action OnLogBusMessage;
+ public event LogBusMessage OnLogBusMessage;
private static Lazy _defaultInstance = new Lazy();
@@ -163,7 +163,7 @@ private async Task ProcessEvent(string eventName, string message)
}
catch (Exception ex)
{
- LogMessage( "error", "There has raised a error when publishing event.", ex);
+ LogMessage( LogLevel.ERROR, "There has raised a error when publishing event.", ex);
}
}
}
@@ -294,7 +294,7 @@ private async Task ProcessRequest(string eventName, string message)
}
catch (Exception ex)
{
- LogMessage("error", "There has raised a error when send request.", ex);
+ LogMessage(LogLevel.ERROR, "There has raised a error when send request.", ex);
}
}
@@ -303,7 +303,7 @@ private async Task ProcessRequest(string eventName, string message)
#endregion
- private void LogMessage(string type, string value, Exception ex)
+ private void LogMessage(LogLevel type, string value, Exception ex)
{
OnLogBusMessage?.Invoke(type, value, ex);
}
diff --git a/test/ServiceAnt.IocInstaller.Castle.test/ServiceAnt.IocInstaller.Castle.Test.csproj b/test/ServiceAnt.IocInstaller.Castle.test/ServiceAnt.IocInstaller.Castle.Test.csproj
index a53669f..91f0227 100644
--- a/test/ServiceAnt.IocInstaller.Castle.test/ServiceAnt.IocInstaller.Castle.Test.csproj
+++ b/test/ServiceAnt.IocInstaller.Castle.test/ServiceAnt.IocInstaller.Castle.Test.csproj
@@ -11,7 +11,7 @@
-
+