incubator-nmaven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r527423 - in /incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging: ./ src/ src/main/ src/main/csharp/ src/main/csharp/NMaven/ src/main/csharp/NMaven/Logging/
Date Wed, 11 Apr 2007 09:04:46 GMT
Author: sisbell
Date: Wed Apr 11 02:04:41 2007
New Revision: 527423

URL: http://svn.apache.org/viewvc?view=rev&rev=527423
Log:
Initial Import of .NET logging module. Need this to control the different output for the IDE:
some loggers write the console, out output pane, etc.

Added:
    incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/
    incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/NMaven.Logging.sln
    incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/pom.xml   (with props)
    incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/
    incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/
    incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/
    incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/
    incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven.Logging.csproj
    incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/
    incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/ConsoleHandler.cs
    incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/IHandler.cs
    incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/Level.cs
    incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/LogManager.cs
    incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/LogRecord.cs
    incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/Logger.cs

Added: incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/NMaven.Logging.sln
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/NMaven.Logging.sln?view=auto&rev=527423
==============================================================================
--- incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/NMaven.Logging.sln (added)
+++ incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/NMaven.Logging.sln Wed Apr
11 02:04:41 2007
@@ -0,0 +1,16 @@
+Microsoft Visual Studio Solution File, Format Version 9.00
+# SharpDevelop 2.0.0.1710
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NMaven.Logging", "src\main\csharp\NMaven.Logging.csproj",
"{7030f644-b1ab-4844-8f09-a6032f1f597c}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{7030F644-B1AB-4844-8F09-A6032F1F597C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{7030F644-B1AB-4844-8F09-A6032F1F597C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{7030F644-B1AB-4844-8F09-A6032F1F597C}.Release|Any CPU.Build.0 = Release|Any CPU
+		{7030F644-B1AB-4844-8F09-A6032F1F597C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+	EndGlobalSection
+EndGlobal

Added: incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/pom.xml
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/pom.xml?view=auto&rev=527423
==============================================================================
--- incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/pom.xml (added)
+++ incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/pom.xml Wed Apr 11 02:04:41
2007
@@ -0,0 +1,13 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0">
+  <parent>
+    <groupId>NMaven</groupId>
+    <version>0.14</version>
+    <artifactId>NMaven.Assemblies</artifactId>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>NMaven.Logging</groupId>
+  <artifactId>NMaven.Logging</artifactId>
+  <packaging>library</packaging>
+  <version>0.14</version>
+  <name>NMaven.Library</name>
+</project>
\ No newline at end of file

Propchange: incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven.Logging.csproj
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven.Logging.csproj?view=auto&rev=527423
==============================================================================
--- incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven.Logging.csproj
(added)
+++ incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven.Logging.csproj
Wed Apr 11 02:04:41 2007
@@ -0,0 +1,31 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ProjectGuid>{7030f644-b1ab-4844-8f09-a6032f1f597c}</ProjectGuid>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <RootNameSpace>NMaven.Logging</RootNameSpace>
+    <AssemblyName>NMaven.Logging</AssemblyName>
+    <BaseIntermediateOutputPath>..\..\..\target\obj\</BaseIntermediateOutputPath>
+    <OutputType>Library</OutputType>
+  </PropertyGroup>
+  <PropertyGroup>
+    <OutputPath>..\..\..\target\bin\Debug\</OutputPath>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="NMaven" />
+    <Folder Include="NMaven\Logging" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="NMaven\Logging\ConsoleHandler.cs" />
+    <Compile Include="NMaven\Logging\IHandler.cs" />
+    <Compile Include="NMaven\Logging\Level.cs" />
+    <Compile Include="NMaven\Logging\Logger.cs" />
+    <Compile Include="NMaven\Logging\LogManager.cs" />
+    <Compile Include="NMaven\Logging\LogRecord.cs" />
+  </ItemGroup>
+  <ItemGroup />
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
+</Project>
\ No newline at end of file

Added: incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/ConsoleHandler.cs
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/ConsoleHandler.cs?view=auto&rev=527423
==============================================================================
--- incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/ConsoleHandler.cs
(added)
+++ incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/ConsoleHandler.cs
Wed Apr 11 02:04:41 2007
@@ -0,0 +1,38 @@
+using System;
+using System.Runtime.CompilerServices;
+
+namespace NMaven.Logging
+{
+
+	public class ConsoleHandler : IHandler
+	{
+		
+		private Level level;
+		
+		public ConsoleHandler()
+		{
+			this.level = Level.INFO;
+		}
+		
+		[MethodImpl(MethodImplOptions.Synchronized)]
+		public void publish(LogRecord record)
+		{
+			if(record.GetLevel().GetValue() >= level.GetValue())
+			{
+				Console.WriteLine(record.GetMessage());
+			}
+		}
+		
+		[MethodImpl(MethodImplOptions.Synchronized)]
+		public void SetLevel(Level level)
+		{
+			this.level = level;
+		}
+		
+		[MethodImpl(MethodImplOptions.Synchronized)]
+		public Level GetLevel()
+		{
+			return level;
+		}
+	}
+}

Added: incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/IHandler.cs
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/IHandler.cs?view=auto&rev=527423
==============================================================================
--- incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/IHandler.cs
(added)
+++ incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/IHandler.cs
Wed Apr 11 02:04:41 2007
@@ -0,0 +1,16 @@
+using System;
+
+namespace NMaven.Logging
+{
+	/// <summary>
+	/// Description of IHandler.
+	/// </summary>
+	public interface IHandler
+	{
+		void publish(LogRecord record);
+		
+		void SetLevel(Level level);
+		
+		Level GetLevel();
+	}
+}

Added: incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/Level.cs
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/Level.cs?view=auto&rev=527423
==============================================================================
--- incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/Level.cs
(added)
+++ incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/Level.cs
Wed Apr 11 02:04:41 2007
@@ -0,0 +1,38 @@
+using System;
+
+namespace NMaven.Logging
+{
+	public class Level
+	{		
+		
+		public static Level SEVERE = new Level("SEVERE", 10);
+		
+		public static Level WARNING = new Level("WARNING", 9);
+		
+		public static Level INFO = new Level("INFO", 8);		
+		
+		public static Level FINE = new Level("FINE", 7);
+		
+		public static Level DEBUG = new Level("DEBUG", 6);		
+		
+		private String name;
+		
+		private int value;
+		
+		private Level(String name, int value)
+		{
+			this.name = name;
+			this.value = value;
+		}
+		
+		public String GetName()
+		{
+			return name;
+		}
+		
+		public int GetValue()
+		{
+			return value;
+		}
+	}
+}

Added: incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/LogManager.cs
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/LogManager.cs?view=auto&rev=527423
==============================================================================
--- incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/LogManager.cs
(added)
+++ incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/LogManager.cs
Wed Apr 11 02:04:41 2007
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.CompilerServices;
+
+namespace NMaven.Logging
+{
+	public class LogManager
+	{
+		
+		private List<Logger> loggers;
+		
+		public LogManager()
+		{
+			loggers = new List<Logger>();
+		}
+		
+		[MethodImpl(MethodImplOptions.Synchronized)]
+		public Logger GetLogger(String name)
+		{
+			foreach(Logger logger in loggers)
+			{
+				if(logger.getName().Equals(name))
+					return logger;
+			}
+			return null;
+		}
+		
+		[MethodImpl(MethodImplOptions.Synchronized)]
+		public void addLogger(Logger logger)
+		{
+			loggers.Add(logger);
+		}
+	}
+}

Added: incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/LogRecord.cs
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/LogRecord.cs?view=auto&rev=527423
==============================================================================
--- incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/LogRecord.cs
(added)
+++ incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/LogRecord.cs
Wed Apr 11 02:04:41 2007
@@ -0,0 +1,30 @@
+using System;
+
+namespace NMaven.Logging
+{
+	/// <summary>
+	/// Description of LogRecord.
+	/// </summary>
+	public class LogRecord
+	{
+		private Level level;
+		
+		private String message;
+		
+		public LogRecord(Level level, String message) 
+		{
+			this.level = level;
+			this.message = message;
+		}
+		
+		public Level GetLevel()
+		{
+			return level;
+		}
+		
+		public String GetMessage()
+		{
+			return message;
+		}
+	}
+}

Added: incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/Logger.cs
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/Logger.cs?view=auto&rev=527423
==============================================================================
--- incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/Logger.cs
(added)
+++ incubator/nmaven/branches/SI_XPT/assemblies/NMaven.Logging/src/main/csharp/NMaven/Logging/Logger.cs
Wed Apr 11 02:04:41 2007
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.CompilerServices;
+
+namespace NMaven.Logging
+{
+	public class Logger 
+	{
+		private List<IHandler> handlers;
+		
+		private String name;
+		
+		private Logger(String name)
+		{
+			handlers = new List<IHandler>();
+			this.name = name;
+		}
+		
+		[MethodImpl(MethodImplOptions.Synchronized)]
+		public static Logger GetLogger(String name)
+		{
+			LogManager logManager = new LogManager();
+			Logger logger = logManager.GetLogger(name);
+			if(logger == null)
+			{
+				logger = new Logger(name);
+				logManager.addLogger(logger);
+			}
+			return logger;
+		}
+		
+		[MethodImpl(MethodImplOptions.Synchronized)]
+		public void Log(Level level, String msg)
+		{
+			Console.WriteLine("[LOG]" + msg);
+			LogRecord logRecord = new LogRecord(level, msg);
+			if(handlers.Count == 0)
+			{
+				handlers.Add(new ConsoleHandler());
+			}
+			foreach(IHandler handler in handlers)
+			{				
+				handler.publish(logRecord);
+			}
+		}
+		
+		[MethodImpl(MethodImplOptions.Synchronized)]
+		public void AddHandler(IHandler handler) 
+		{
+			handlers.Add(handler);
+		}
+		
+		public String getName()
+		{
+			return name;			
+		}
+	}
+}



Mime
View raw message