Changeset 4754

Show
Ignore:
Timestamp:
07/23/08 18:30:02 (4 months ago)
Author:
xmlhacker
Message:

provides logging capabilities to all objects

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/nuxleus/Source/Nuxleus.Extension/Log/Log.cs

    r4731 r4754  
    66using log4net.Config; 
    77using log4net.Core; 
    8  
    9 namespace Nuxleus.Extension.Log { 
     8using System.Security.Permissions; 
     9 
     10namespace Nuxleus.Extension { 
     11 
     12    [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.AllFlags)] 
    1013    public static class Log { 
    1114 
     
    1821        } 
    1922 
     23        public static ILog GetLogger<T>() { 
     24            if (!IsConfigured) 
     25                Config(); 
     26            return LogManager.GetLogger(typeof(T)); 
     27        } 
     28 
    2029        private static ILog Logger(object obj) { 
    2130            if(!IsConfigured)  
    2231                Config(); 
    2332            return LogManager.GetLogger(obj.GetType()); 
     33        } 
     34 
     35        private static ILog Logger<T>() { 
     36            if (!IsConfigured) 
     37                Config(); 
     38            return LogManager.GetLogger(typeof(T)); 
     39        } 
     40 
     41        public static void Config(string logFile) { 
     42            XmlConfigurator.Configure(new System.IO.FileInfo((logFile))); 
     43            IsConfigured = true; 
    2444        } 
    2545 
     
    4565        } 
    4666 
     67        public static void LogDebug<T>(object message, Exception exception) { 
     68            Logger<T>().Debug(message, exception); 
     69        } 
     70 
     71        public static void LogDebug<T>(object message) { 
     72            Logger<T>().Debug(message); 
     73        } 
     74 
     75        public static void LogDebug<T>(IFormatProvider provider, string format, params object[] args) { 
     76            Logger<T>().DebugFormat(provider, format, args); 
     77        } 
     78 
     79        public static void LogDebug<T>(string format, params object[] args) { 
     80            Logger<T>().DebugFormat(format, args); 
     81        } 
     82 
    4783        public static void LogError(this object obj, object message, Exception exception) { 
    4884            Logger(obj).Error(message, exception); 
     
    6197        } 
    6298 
     99        public static void LogError<T>(object message, Exception exception) { 
     100            Logger<T>().Error(message, exception); 
     101        } 
     102 
     103        public static void LogError<T>(object message) { 
     104            Logger<T>().Error(message); 
     105        } 
     106 
     107        public static void LogError<T>(IFormatProvider provider, string format, params object[] args) { 
     108            Logger<T>().ErrorFormat(provider, format, args); 
     109        } 
     110 
     111        public static void LogError<T>(string format, params object[] args) { 
     112            Logger<T>().ErrorFormat(format, args); 
     113        } 
     114 
    63115        public static void LogFatal(this object obj, object message, Exception exception) { 
    64116            Logger(obj).Fatal(message, exception); 
     
    77129        } 
    78130 
     131        public static void LogFatal<T>(object message, Exception exception) { 
     132            Logger<T>().Fatal(message, exception); 
     133        } 
     134 
     135        public static void LogFatal<T>(object message) { 
     136            Logger<T>().Fatal(message); 
     137        } 
     138 
     139        public static void LogFatal<T>(IFormatProvider provider, string format, params object[] args) { 
     140            Logger<T>().FatalFormat(provider, format, args); 
     141        } 
     142 
     143        public static void LogFatal<T>(string format, params object[] args) { 
     144            Logger<T>().FatalFormat(format, args); 
     145        } 
     146 
    79147        public static void LogInfo(this object obj, object message, Exception exception) { 
    80148            Logger(obj).Info(message, exception); 
     
    93161        } 
    94162 
     163        public static void LogInfo<T>(object message, Exception exception) { 
     164            Logger<T>().Info(message, exception); 
     165        } 
     166 
     167        public static void LogInfo<T>(object message) { 
     168            Logger<T>().Info(message); 
     169        } 
     170 
     171        public static void LogInfo<T>(IFormatProvider provider, string format, params object[] args) { 
     172            Logger<T>().InfoFormat(provider, format, args); 
     173        } 
     174 
     175        public static void LogInfo<T>(string format, params object[] args) { 
     176            Logger<T>().InfoFormat(format, args); 
     177        } 
     178 
    95179        public static void LogWarn(this object obj, object message, Exception exception) { 
    96180            Logger(obj).Warn(message, exception); 
     
    109193        } 
    110194 
     195        public static void LogWarn<T>(object message, Exception exception) { 
     196            Logger<T>().Warn(message, exception); 
     197        } 
     198 
     199        public static void LogWarn<T>(object message) { 
     200            Logger<T>().Warn(message); 
     201        } 
     202 
     203        public static void LogWarn<T>(IFormatProvider provider, string format, params object[] args) { 
     204            Logger<T>().WarnFormat(provider, format, args); 
     205        } 
     206 
     207        public static void LogWarn<T>(string format, params object[] args) { 
     208            Logger<T>().WarnFormat(format, args); 
     209        } 
    111210    } 
    112211} 
  • trunk/nuxleus/Source/Nuxleus.Extension/Properties/AssemblyInfo.cs

    r3987 r4754  
    22using System.Runtime.CompilerServices; 
    33using System.Runtime.InteropServices; 
     4using System.Security; 
    45 
    56// General Information about an assembly is controlled through the following  
     
    3536[assembly: AssemblyVersion("1.0.0.0")] 
    3637[assembly: AssemblyFileVersion("1.0.0.0")] 
     38[assembly: AllowPartiallyTrustedCallers]