#region Copyright 2008-2014 by Roger Knapp, Licensed under the Apache License, Version 2.0 /* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion using System; namespace CSharpTest.Net.Logging { /// /// Defines the various levels of logging /// public enum LogLevels : int { /// Logging is disabled None = System.Diagnostics.SourceLevels.Off, /// Logs a Fatal error Critical = System.Diagnostics.SourceLevels.Critical, /// Logs an Error Error = System.Diagnostics.SourceLevels.Error, /// Logs a Warning Warning = System.Diagnostics.SourceLevels.Warning, /// Logs an Informational message Info = System.Diagnostics.SourceLevels.Information, /// Logs a Verbose message Verbose = System.Diagnostics.SourceLevels.Verbose, // Logs all activity start/stop and time and enables performance counters // someday: PerformanceCounts = System.Diagnostics.SourceLevels.ActivityTracing, } /// /// Defines the various possble outputs of the logging system /// public enum LogOutputs : ushort { /// No default destination (Event will still fire if anyone is subscribed) None = 0x0000, /// Outputs messages to the System.Diagnostics.Trace.WriteLine() method /// Note: Always on by default when System.Diagnostics.Debugger.IsAttached == true TraceWrite = 0x0001, /// Outputs messages to this process' log file /// Note: Always on by default to \Users\{Current}\AppData\Local\{Process Name}\{Process File Name}.log LogFile = 0x0002, /// Outputs messages to the Console.[Out/Error].WriteLine() methods /// Note: Always on by default when running as a console application Console = 0x0004, /// Outputs messages to the System.Web.HttpContext.Current.Trace.[Write/Warn]() methods /// Note: Always on by default when /configuration/system.web/trace/@enabled == true AspNetTrace = 0x0008, /// Outputs messages to the event log /// Note: Always on by default for Critical errors only EventLog = 0x0010, /// Writes to all LogOutput types available All = 0xFFFF } /// /// Performance and behavior related LogOption for the log system. /// public enum LogOptions { /// /// These are the default options used. Addtionally, if your debugging or using asp.net trace, /// the following will also be set: LogAddFileInfo /// Default = LogImmediateCaller | GZipLogFileOnRoll, /// /// No LogOption enabled /// None = 0, /// /// Calls new StackFrame( n ) to retrieve the immediate caller of the log routine and pass /// it along to all logging information. /// LogImmediateCaller = 0x0001, /// /// Starting with n frames back walk back until the calling class is not decorated with the /// ////[System.Diagnostics.DebuggerNonUserCode()] attribute. This allows you to create wrapper /// classes that provide logging but are not considered to be the point of origin in the log. /// Can be slightly slower as this now reflects each class' attributes and addtionally may /// gather more than one stack frame. /// LogNearestCaller = 0x0003, /// /// If this is specified the file and line number where the log call was made will be available /// to log LogOutput. /// LogAddFileInfo = 0x0005, /// /// Uses a different color based on the level of the log message, Use ONLY nothing else is /// writting to the console. /// ConsoleColors = 0x0008, /// /// Populate the MethodAssemblyVersion and MethodAssembly properties for logging. Requires /// at least the LogImmediateCaller information. /// LogAddAssemblyInfo = 0x0011, /// /// GZip and append a .gz extension to log files as they are rolled, the current log file /// will remain unzipped. /// GZipLogFileOnRoll = 0x0020, } }