@levels = ('Log', 'Trace','Debug','Info','Warn','Error','Fatal'); @clitypes = ('System.Boolean','System.Char','System.Byte','System.String','System.Int32','System.Int64','System.Single','System.Double','System.Decimal','System.Object'); @nonclstypes = ('System.SByte','System.UInt32','System.UInt64'); $loggercs = "../src/NLog/Logger.cs"; open(IN, "<$loggercs"); open(OUT, ">$loggercs.tmp"); while () { print OUT; last if (m/the following code has been automatically generated by a PERL/); } for $level (@levels) { if ($level eq "Log") { $level2 = "level"; $level3 = "specified"; $isenabled = "this.IsEnabled(level)"; $arg0 = "LogLevel level, "; $param0 = qq!\n /// The log level.!; } else { $level2 = "LogLevel.$level"; $level3 = "$level"; $isenabled = "this.Is${level}Enabled"; $arg0 = ""; $param0 = ""; } print OUT < /// Writes the diagnostic message at the $level3 level using the specified format provider and format parameters. /// /// /// Writes the diagnostic message at the $level3 level. /// /// Type of the value.$param0 /// The value to be written. public void $level(${arg0}T value) { if ($isenabled) { this.WriteToTargets($level2, null, value); } } /// /// Writes the diagnostic message at the $level3 level. /// /// Type of the value.$param0 /// An IFormatProvider that supplies culture-specific formatting information. /// The value to be written. public void $level(${arg0}IFormatProvider formatProvider, T value) { if ($isenabled) { this.WriteToTargets($level2, formatProvider, value); } } /// /// Writes the diagnostic message at the $level3 level. /// $param0 /// A function returning message to be written. Function is not evaluated if logging is not enabled. public void $level(${arg0}LogMessageGenerator messageFunc) { if ($isenabled) { this.WriteToTargets($level2, null, messageFunc()); } } /// /// Writes the diagnostic message and exception at the $level3 level. /// $param0 /// A to be written. /// An exception to be logged. public void ${level}Exception(${arg0}string message, Exception exception) { if ($isenabled) { this.WriteToTargets($level2, message, exception); } } /// /// Writes the diagnostic message at the $level3 level using the specified parameters and formatting them with the supplied format provider. /// $param0 /// An IFormatProvider that supplies culture-specific formatting information. /// A containing format items. /// Arguments to format. public void $level(${arg0}IFormatProvider formatProvider, string message, params object[] args) { if ($isenabled) { this.WriteToTargets($level2, formatProvider, message, args); } } /// /// Writes the diagnostic message at the $level3 level. /// $param0 /// Log message. public void $level(${arg0}string message) { if ($isenabled) { this.WriteToTargets($level2, null, message); } } /// /// Writes the diagnostic message at the $level3 level using the specified parameters. /// $param0 /// A containing format items. /// Arguments to format. public void $level(${arg0}string message, params object[] args) { if ($isenabled) { this.WriteToTargets($level2, message, args); } } /// /// Writes the diagnostic message at the $level3 level using the specified parameter and formatting it with the supplied format provider. /// /// The type of the argument.$param0 /// An IFormatProvider that supplies culture-specific formatting information. /// A containing one format item. /// The argument to format. public void $level(${arg0}IFormatProvider formatProvider, string message, TArgument argument) { if ($isenabled) { this.WriteToTargets($level2, formatProvider, message, new object[] { argument }); } } /// /// Writes the diagnostic message at the $level3 level using the specified parameter. /// /// The type of the argument.$param0 /// A containing one format item. /// The argument to format. public void $level(${arg0}string message, TArgument argument) { if ($isenabled) { this.WriteToTargets($level2, message, new object[] { argument }); } } /// /// Writes the diagnostic message at the $level3 level using the specified arguments formatting it with the supplied format provider. /// /// The type of the first argument. /// The type of the second argument.$param0 /// An IFormatProvider that supplies culture-specific formatting information. /// A containing one format item. /// The first argument to format. /// The second argument to format. public void $level(${arg0}IFormatProvider formatProvider, string message, TArgument1 argument1, TArgument2 argument2) { if ($isenabled) { this.WriteToTargets($level2, formatProvider, message, new object[] { argument1, argument2 }); } } /// /// Writes the diagnostic message at the $level3 level using the specified parameters. /// /// The type of the first argument. /// The type of the second argument.$param0 /// A containing one format item. /// The first argument to format. /// The second argument to format. public void $level(${arg0}string message, TArgument1 argument1, TArgument2 argument2) { if ($isenabled) { this.WriteToTargets($level2, message, new object[] { argument1, argument2 }); } } /// /// Writes the diagnostic message at the $level3 level using the specified arguments formatting it with the supplied format provider. /// /// The type of the first argument. /// The type of the second argument. /// The type of the third argument.$param0 /// An IFormatProvider that supplies culture-specific formatting information. /// A containing one format item. /// The first argument to format. /// The second argument to format. /// The third argument to format. public void $level(${arg0}IFormatProvider formatProvider, string message, TArgument1 argument1, TArgument2 argument2, TArgument3 argument3) { if ($isenabled) { this.WriteToTargets($level2, formatProvider, message, new object[] { argument1, argument2, argument3 }); } } /// /// Writes the diagnostic message at the $level3 level using the specified parameters. /// /// The type of the first argument. /// The type of the second argument. /// The type of the third argument.$param0 /// A containing one format item. /// The first argument to format. /// The second argument to format. /// The third argument to format. public void $level(${arg0}string message, TArgument1 argument1, TArgument2 argument2, TArgument3 argument3) { if ($isenabled) { this.WriteToTargets($level2, message, new object[] { argument1, argument2, argument3 }); } } #endregion EOT } while () { if (m/end of generated code/) { print OUT; last; } } while () { print OUT; } close(OUT); close(IN); unlink($loggercs); rename("$loggercs.tmp", "$loggercs");