diff options
| author | mokhan <mokhan@da190166-9cfc-4ee1-ae03-434a172be219> | 2009-02-21 21:44:27 +0000 |
|---|---|---|
| committer | mokhan <mokhan@da190166-9cfc-4ee1-ae03-434a172be219> | 2009-02-21 21:44:27 +0000 |
| commit | 1dfdccb8118aeaa3cd844ac8de2a672c93312166 (patch) | |
| tree | 4b19e7f816ab1019f180a46b68572af4b66fe4bc /slips/src/app/Marina/Infrastructure/Logging | |
| parent | 42d66bcab8262c7b8b2452615df535e694a3ec1c (diff) | |
git-svn-id: http://svn.xp-dev.com/svn/mokhan-sait@2 da190166-9cfc-4ee1-ae03-434a172be219
Diffstat (limited to 'slips/src/app/Marina/Infrastructure/Logging')
9 files changed, 142 insertions, 0 deletions
diff --git a/slips/src/app/Marina/Infrastructure/Logging/Interfaces/ILog.cs b/slips/src/app/Marina/Infrastructure/Logging/Interfaces/ILog.cs new file mode 100644 index 0000000..37d91d8 --- /dev/null +++ b/slips/src/app/Marina/Infrastructure/Logging/Interfaces/ILog.cs @@ -0,0 +1,7 @@ +namespace Marina.Infrastructure.Logging.Interfaces {
+ public interface ILog {
+ void Informational( string message );
+ void Informational( string messageFormat, params object[] args );
+ void CriticalError( string messageFormat, params object[] args );
+ }
+}
\ No newline at end of file diff --git a/slips/src/app/Marina/Infrastructure/Logging/Interfaces/ILogFactory.cs b/slips/src/app/Marina/Infrastructure/Logging/Interfaces/ILogFactory.cs new file mode 100644 index 0000000..0c71caf --- /dev/null +++ b/slips/src/app/Marina/Infrastructure/Logging/Interfaces/ILogFactory.cs @@ -0,0 +1,7 @@ +using System;
+
+namespace Marina.Infrastructure.Logging.Interfaces {
+ public interface ILogFactory {
+ ILog CreateFor( Type type );
+ }
+}
\ No newline at end of file diff --git a/slips/src/app/Marina/Infrastructure/Logging/Interfaces/Log.cs b/slips/src/app/Marina/Infrastructure/Logging/Interfaces/Log.cs new file mode 100644 index 0000000..c8dae76 --- /dev/null +++ b/slips/src/app/Marina/Infrastructure/Logging/Interfaces/Log.cs @@ -0,0 +1,14 @@ +using System;
+using Marina.Infrastructure.Container;
+
+namespace Marina.Infrastructure.Logging.Interfaces {
+ public class Log {
+ public static ILog For( object itemThatRequiresLoggingServices ) {
+ return For( itemThatRequiresLoggingServices.GetType( ) );
+ }
+
+ public static ILog For( Type type ) {
+ return Resolve.DependencyFor< ILogFactory >( ).CreateFor( type );
+ }
+ }
+}
\ No newline at end of file diff --git a/slips/src/app/Marina/Infrastructure/Logging/Log4Net/ILog4NetInitializationCommand.cs b/slips/src/app/Marina/Infrastructure/Logging/Log4Net/ILog4NetInitializationCommand.cs new file mode 100644 index 0000000..a688728 --- /dev/null +++ b/slips/src/app/Marina/Infrastructure/Logging/Log4Net/ILog4NetInitializationCommand.cs @@ -0,0 +1,8 @@ +using System.Xml;
+using log4net.Config;
+
+namespace Marina.Infrastructure.Logging.Log4Net {
+ public interface ILog4NetInitializationCommand {
+ void Execute( );
+ }
+}
\ No newline at end of file diff --git a/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetInitializationCommand.cs b/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetInitializationCommand.cs new file mode 100644 index 0000000..888a088 --- /dev/null +++ b/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetInitializationCommand.cs @@ -0,0 +1,19 @@ +using System.Xml;
+using log4net.Config;
+using Marina.Infrastructure.Configuration;
+
+namespace Marina.Infrastructure.Logging.Log4Net {
+ public class Log4NetInitializationCommand : ILog4NetInitializationCommand {
+ private readonly XmlElement configuration;
+
+ public Log4NetInitializationCommand( ) : this( ConfigurationItems.Log4NetConfigFile.Value( ) ) {}
+
+ public Log4NetInitializationCommand( XmlElement configuration ) {
+ this.configuration = configuration;
+ }
+
+ public void Execute( ) {
+ XmlConfigurator.Configure( configuration );
+ }
+ }
+}
\ No newline at end of file diff --git a/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetLog.cs b/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetLog.cs new file mode 100644 index 0000000..a225f55 --- /dev/null +++ b/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetLog.cs @@ -0,0 +1,23 @@ +using Marina.Infrastructure.Logging.Interfaces;
+
+namespace Marina.Infrastructure.Logging.Log4Net {
+ public class Log4NetLog : ILog {
+ private log4net.ILog logToAdapt;
+
+ public Log4NetLog( log4net.ILog logToAdapt ) {
+ this.logToAdapt = logToAdapt;
+ }
+
+ public void Informational( string message ) {
+ logToAdapt.Info( message );
+ }
+
+ public void Informational( string messageFormat, params object[] args ) {
+ logToAdapt.InfoFormat( messageFormat, args );
+ }
+
+ public void CriticalError( string messageFormat, params object[] args ) {
+ logToAdapt.ErrorFormat( messageFormat, args );
+ }
+ }
+}
\ No newline at end of file diff --git a/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetLogFactory.cs b/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetLogFactory.cs new file mode 100644 index 0000000..996557f --- /dev/null +++ b/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetLogFactory.cs @@ -0,0 +1,30 @@ +using System;
+using log4net;
+using Marina.Infrastructure.Logging.Interfaces;
+using ILog=Marina.Infrastructure.Logging.Interfaces.ILog;
+
+namespace Marina.Infrastructure.Logging.Log4Net {
+ public class Log4NetLogFactory : ILogFactory {
+ private ILog4NetInitializationCommand initializationCommand;
+ private bool initialized;
+
+ public Log4NetLogFactory( ) : this( new Log4NetInitializationCommand( ) ) {}
+
+ public Log4NetLogFactory( ILog4NetInitializationCommand initializationCommand ) {
+ this.initializationCommand = initializationCommand;
+ }
+
+ public ILog CreateFor( Type typeThatRequiresLoggingServices ) {
+ WireUpConfiguration( );
+ return new Log4NetLog( LogManager.GetLogger( typeThatRequiresLoggingServices ) );
+ }
+
+ private void WireUpConfiguration( ) {
+ if ( initialized ) {
+ return;
+ }
+ initialized = true;
+ initializationCommand.Execute( );
+ }
+ }
+}
\ No newline at end of file diff --git a/slips/src/app/Marina/Infrastructure/Logging/TextWriterLogging/TextWriterLog.cs b/slips/src/app/Marina/Infrastructure/Logging/TextWriterLogging/TextWriterLog.cs new file mode 100644 index 0000000..858d0f7 --- /dev/null +++ b/slips/src/app/Marina/Infrastructure/Logging/TextWriterLogging/TextWriterLog.cs @@ -0,0 +1,24 @@ +using System.IO;
+using Marina.Infrastructure.Logging.Interfaces;
+
+namespace Marina.Infrastructure.Logging.TextWriterLogging {
+ public class TextWriterLog : ILog {
+ private readonly TextWriter _writer;
+
+ public TextWriterLog( TextWriter writer ) {
+ _writer = writer;
+ }
+
+ public void Informational( string message ) {
+ _writer.WriteLine( message );
+ }
+
+ public void Informational( string messageFormat, params object[] args ) {
+ _writer.WriteLine( messageFormat, args );
+ }
+
+ public void CriticalError( string messageFormat, params object[] args ) {
+ Informational( messageFormat, args );
+ }
+ }
+}
\ No newline at end of file diff --git a/slips/src/app/Marina/Infrastructure/Logging/TextWriterLogging/TextWriterLogFactory.cs b/slips/src/app/Marina/Infrastructure/Logging/TextWriterLogging/TextWriterLogFactory.cs new file mode 100644 index 0000000..7a2b344 --- /dev/null +++ b/slips/src/app/Marina/Infrastructure/Logging/TextWriterLogging/TextWriterLogFactory.cs @@ -0,0 +1,10 @@ +using System;
+using Marina.Infrastructure.Logging.Interfaces;
+
+namespace Marina.Infrastructure.Logging.TextWriterLogging {
+ public class TextWriterLogFactory : ILogFactory {
+ public ILog CreateFor( Type type ) {
+ return new TextWriterLog( Console.Out );
+ }
+ }
+}
\ No newline at end of file |
