Cleanup ILogger

This commit is contained in:
Stephan
2018-04-03 16:15:59 +02:00
parent e3c6205d0c
commit 553de2ea68
37 changed files with 122 additions and 292 deletions

View File

@@ -33,7 +33,7 @@ namespace Umbraco.Core.Logging
public static void Warn(Type callingType, string message, params Func<object>[] formatItems)
{
Current.Logger.Warn(callingType, message, formatItems);
Current.Logger.Warn(callingType, () => string.Format(message, formatItems.Select(x => x.Invoke()).ToArray()));
}
[Obsolete("Warnings with http trace should not be used. This method will be removed in future versions")]
@@ -47,8 +47,7 @@ namespace Umbraco.Core.Logging
HttpContext.Current.Trace.Warn(callingType.Name, string.Format(message, formatItems.Select(x => x.Invoke()).ToArray()));
}
Current.Logger.Warn(callingType, message, formatItems);
Current.Logger.Warn(callingType, () => string.Format(message, formatItems.Select(x => x.Invoke()).ToArray()));
}
[Obsolete("Warnings with http trace should not be used. This method will be removed in future versions")]
@@ -72,7 +71,7 @@ namespace Umbraco.Core.Logging
e);
}
Current.Logger.Warn(callingType, e, message, formatItems);
Current.Logger.Warn(callingType, e, string.Format(message, formatItems.Select(x => x.Invoke()).ToArray()));
}
/// <summary>
@@ -136,7 +135,7 @@ namespace Umbraco.Core.Logging
/// <param name="formatItems">The format items.</param>
public static void Info(Type type, string generateMessageFormat, params Func<object>[] formatItems)
{
Current.Logger.Info(type, generateMessageFormat, formatItems);
Current.Logger.Info(type, string.Format(generateMessageFormat, formatItems.Select(x => x.Invoke()).ToArray()));
}
/// <summary>
@@ -182,7 +181,7 @@ namespace Umbraco.Core.Logging
/// <param name="formatItems">The format items.</param>
public static void Debug(Type type, string generateMessageFormat, params Func<object>[] formatItems)
{
Current.Logger.Debug(type, generateMessageFormat, formatItems);
Current.Logger.Debug(type, string.Format(generateMessageFormat, formatItems.Select(x => x.Invoke()).ToArray()));
}
/// <summary>

View File

@@ -642,7 +642,7 @@ namespace Umbraco.Core.Composing
if (typeList != null)
{
// need to put some logging here to try to figure out why this is happening: http://issues.umbraco.org/issue/U4-3505
_logger.Logger.Debug<TypeLoader>("Getting {0}: found a cached type list.", () => GetName(baseType, attributeType));
_logger.Logger.Debug<TypeLoader>(() => $"Getting {GetName(baseType, attributeType)}: found a cached type list.");
return typeList.Types;
}
@@ -673,7 +673,7 @@ namespace Umbraco.Core.Composing
// so in this instance there will never be a result.
if (cacheResult.Exception is CachedTypeNotFoundInFileException || cacheResult.Success == false)
{
_logger.Logger.Debug<TypeLoader>("Getting {0}: failed to load from cache file, must scan assemblies.", () => GetName(baseType, attributeType));
_logger.Logger.Debug<TypeLoader>(() => $"Getting {GetName(baseType, attributeType)}: failed to load from cache file, must scan assemblies.");
scan = true;
}
else
@@ -700,7 +700,7 @@ namespace Umbraco.Core.Composing
if (scan == false)
{
_logger.Logger.Debug<TypeLoader>("Getting {0}: loaded types from cache file.", () => GetName(baseType, attributeType));
_logger.Logger.Debug<TypeLoader>(() => $"Getting {GetName(baseType, attributeType)}: loaded types from cache file.");
}
}
}
@@ -708,7 +708,7 @@ namespace Umbraco.Core.Composing
if (scan)
{
// either we had to scan, or we could not get the types from the cache file - scan now
_logger.Logger.Debug<TypeLoader>("Getting {0}: scanning assemblies.", () => GetName(baseType, attributeType));
_logger.Logger.Debug<TypeLoader>(() => $"Getting {GetName(baseType, attributeType)}: scanning assemblies.");
foreach (var t in finder())
typeList.Add(t);
@@ -726,11 +726,11 @@ namespace Umbraco.Core.Composing
UpdateCache();
}
_logger.Logger.Debug<TypeLoader>("Got {0}, caching ({1}).", () => GetName(baseType, attributeType), () => added.ToString().ToLowerInvariant());
_logger.Logger.Debug<TypeLoader>(() => $"Got {GetName(baseType, attributeType)}, caching ({added.ToString().ToLowerInvariant()}).");
}
else
{
_logger.Logger.Debug<TypeLoader>("Got {0}.", () => GetName(baseType, attributeType));
_logger.Logger.Debug<TypeLoader>(() => $"Got {GetName(baseType, attributeType)}.");
}
return typeList.Types;

View File

@@ -32,14 +32,6 @@ namespace Umbraco.Core.Logging
/// <param name="messageBuilder">A message builder.</param>
void Warn(Type reporting, Func<string> messageBuilder);
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method will be removed, do not use it, if you want to use formatting do it with string interpolation")]
void Warn(Type reporting, string format, params object[] args);
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method will be removed, do not use it, if you want to use formatting do it with string interpolation, if you want to use lazy generated strings use the overload with messageBuilder")]
void Warn(Type reporting, string format, params Func<object>[] args);
/// <summary>
/// Logs a warning message with an exception.
/// </summary>
@@ -56,14 +48,6 @@ namespace Umbraco.Core.Logging
/// <param name="messageBuilder">A message builder.</param>
void Warn(Type reporting, Exception exception, Func<string> messageBuilder);
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method will be removed, do not use it, if you want to use formatting do it with string interpolation")]
void Warn(Type reporting, Exception exception, string format, params object[] args);
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method will be removed, do not use it, if you want to use formatting do it with string interpolation, if you want to use lazy generated strings use the overload with messageBuilder")]
void Warn(Type reporting, Exception exception, string format, params Func<object>[] args);
/// <summary>
/// Logs an information message.
/// </summary>
@@ -78,14 +62,6 @@ namespace Umbraco.Core.Logging
/// <param name="messageBuilder">A message builder.</param>
void Info(Type reporting, Func<string> messageBuilder);
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method will be removed, do not use it, if you want to use formatting do it with string interpolation")]
void Info(Type reporting, string format, params object[] args);
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method will be removed, do not use it, if you want to use formatting do it with string interpolation, if you want to use lazy generated strings use the overload with messageBuilder")]
void Info(Type reporting, string format, params Func<object>[] args);
/// <summary>
/// Logs a debugging message.
/// </summary>
@@ -99,13 +75,5 @@ namespace Umbraco.Core.Logging
/// <param name="reporting">The reporting type.</param>
/// <param name="messageBuilder">A message builder.</param>
void Debug(Type reporting, Func<string> messageBuilder);
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method will be removed, do not use it, if you want to use formatting do it with string interpolation")]
void Debug(Type reporting, string format, params object[] args);
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method will be removed, do not use it, if you want to use formatting do it with string interpolation, if you want to use lazy generated strings use the overload with messageBuilder")]
void Debug(Type reporting, string format, params Func<object>[] args);
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Linq;
namespace Umbraco.Core.Logging
{
@@ -41,30 +42,6 @@ namespace Umbraco.Core.Logging
logger.Warn(typeof(T), messageBuilder);
}
/// <summary>
/// Logs a formatted warning message.
/// </summary>
/// <typeparam name="T">The reporting type.</typeparam>
/// <param name="logger">The logger.</param>
/// <param name="format">A composite format string.</param>
/// <param name="args">An array of objects to format.</param>
public static void Warn<T>(this ILogger logger, string format, params object[] args)
{
logger.Warn(typeof(T), format, args);
}
/// <summary>
/// Logs a formatted warning message.
/// </summary>
/// <typeparam name="T">The reporting type.</typeparam>
/// <param name="logger">The logger.</param>
/// <param name="format">A composite format string.</param>
/// <param name="args">An array of functions returning objects to format.</param>
public static void Warn<T>(this ILogger logger, string format, params Func<object>[] args)
{
logger.Warn(typeof(T), format, args);
}
/// <summary>
/// Logs a formatted warning message with an exception.
/// </summary>
@@ -89,32 +66,6 @@ namespace Umbraco.Core.Logging
logger.Warn(typeof(T), exception, message);
}
/// <summary>
/// Logs a formatted warning message with an exception.
/// </summary>
/// <typeparam name="T">The reporting type.</typeparam>
/// <param name="logger">The logger.</param>
/// <param name="exception">An exception.</param>
/// <param name="format">A composite format string.</param>
/// <param name="args">An array of objects to format.</param>
public static void Warn<T>(this ILogger logger, Exception exception, string format, params object[] args)
{
logger.Warn(typeof(T), exception, format, args);
}
/// <summary>
/// Logs a formatted warning message with an exception.
/// </summary>
/// <typeparam name="T">The reporting type.</typeparam>
/// <param name="logger">The logger.</param>
/// <param name="exception">An exception.</param>
/// <param name="format">A composite format string.</param>
/// <param name="args">An array of functions returning objects to format.</param>
public static void Warn<T>(this ILogger logger, Exception exception, string format, params Func<object>[] args)
{
logger.Warn(typeof(T), exception, format, args);
}
/// <summary>
/// Logs an information message.
/// </summary>
@@ -137,30 +88,6 @@ namespace Umbraco.Core.Logging
logger.Info(typeof(T), messageBuilder);
}
/// <summary>
/// Logs a formatted information message.
/// </summary>
/// <typeparam name="T">The reporting type.</typeparam>
/// <param name="logger">The logger.</param>
/// <param name="format">A composite format string.</param>
/// <param name="args">An array of objects to format.</param>
public static void Info<T>(this ILogger logger, string format, params object[] args)
{
logger.Info(typeof(T), format, args);
}
/// <summary>
/// Logs a formatted information message.
/// </summary>
/// <typeparam name="T">The reporting type.</typeparam>
/// <param name="logger">The logger.</param>
/// <param name="format">A composite format string.</param>
/// <param name="args">An array of functions returning objects to format.</param>
public static void Info<T>(this ILogger logger, string format, params Func<object>[] args)
{
logger.Info(typeof(T), format, args);
}
/// <summary>
/// Logs a debugging message.
/// </summary>
@@ -182,29 +109,5 @@ namespace Umbraco.Core.Logging
{
logger.Debug(typeof(T), messageBuilder);
}
/// <summary>
/// Logs a formatted debugging message.
/// </summary>
/// <typeparam name="T">The reporting type.</typeparam>
/// <param name="logger">The logger.</param>
/// <param name="format">A composite format string.</param>
/// <param name="args">An array of objects to format.</param>
public static void Debug<T>(this ILogger logger, string format, params object[] args)
{
logger.Debug(typeof(T), format, args);
}
/// <summary>
/// Logs a formatted debugging message.
/// </summary>
/// <typeparam name="T">The reporting type.</typeparam>
/// <param name="logger">The logger.</param>
/// <param name="format">A composite format string.</param>
/// <param name="args">An array of functions returning objects to format.</param>
public static void Debug<T>(this ILogger logger, string format, params Func<object>[] args)
{
logger.Debug(typeof(T), format, args);
}
}
}

View File

@@ -308,7 +308,7 @@ namespace Umbraco.Core.Migrations.Install
{
var source = connectionStrings.Attribute("configSource").Value;
var configFile = IOHelper.MapPath($"{SystemDirectories.Root}/{source}");
logger.Info<DatabaseBuilder>("storing ConnectionString in {0}", () => configFile);
logger.Info<DatabaseBuilder>($"Storing ConnectionString in {configFile}");
if (File.Exists(configFile))
{
xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);

View File

@@ -211,7 +211,7 @@ namespace Umbraco.Core.Migrations
if (_migrationBuilder == null || _logger == null)
throw new InvalidOperationException("Cannot execute a non-executing plan.");
_logger.Info<MigrationPlan>("Starting \"{0}\"...", () => Name);
_logger.Info<MigrationPlan>($"Starting \"{Name}\"...");
var origState = fromState ?? string.Empty;
var info = "At " + (string.IsNullOrWhiteSpace(origState) ? "origin" : ("\"" + origState + "\"")) + ".";
info = info.Replace("{", "{{").Replace("}", "}}"); // stupid log4net
@@ -230,7 +230,7 @@ namespace Umbraco.Core.Migrations
var nextState = transition.TargetState;
origState = nextState;
_logger.Info<MigrationPlan>("At \"{0}\".", origState);
_logger.Info<MigrationPlan>($"At \"{origState}\".");
if (!_transitions.TryGetValue(origState, out transition))
throw new Exception($"Unknown state \"{origState}\".");

View File

@@ -120,8 +120,7 @@ namespace Umbraco.Core.Persistence
}
catch (Exception ex)
{
Current.Logger.Warn(typeof(DbConnectionExtensions),
"Could not resolve connection string parameters", ex);
Current.Logger.Warn(typeof(DbConnectionExtensions), ex, "Could not resolve connection string parameters");
return "(Could not resolve)";
}

View File

@@ -104,7 +104,7 @@ namespace Umbraco.Core.Services.Implement
{
if (xmlSource.ContainsKey(culture) == false)
{
_logger.Warn<LocalizedTextService>("The culture specified {0} was not found in any configured sources for this service", () => culture);
_logger.Warn<LocalizedTextService>(() => $"The culture specified {culture} was not found in any configured sources for this service");
return result;
}
@@ -124,7 +124,7 @@ namespace Umbraco.Core.Services.Implement
{
if (_dictionarySource.ContainsKey(culture) == false)
{
_logger.Warn<LocalizedTextService>("The culture specified {0} was not found in any configured sources for this service", () => culture);
_logger.Warn<LocalizedTextService>(() => $"The culture specified {culture} was not found in any configured sources for this service");
return result;
}
@@ -224,7 +224,7 @@ namespace Umbraco.Core.Services.Implement
{
if (_dictionarySource.ContainsKey(culture) == false)
{
_logger.Warn<LocalizedTextService>("The culture specified {0} was not found in any configured sources for this service", () => culture);
_logger.Warn<LocalizedTextService>(() => $"The culture specified {culture} was not found in any configured sources for this service");
return "[" + key + "]";
}
@@ -262,7 +262,7 @@ namespace Umbraco.Core.Services.Implement
{
if (xmlSource.ContainsKey(culture) == false)
{
_logger.Warn<LocalizedTextService>("The culture specified {0} was not found in any configured sources for this service", () => culture);
_logger.Warn<LocalizedTextService>(() => $"The culture specified {culture} was not found in any configured sources for this service");
return "[" + key + "]";
}

View File

@@ -126,7 +126,7 @@ namespace Umbraco.Core.Services.Implement
if (fileSourceFolder.Exists == false)
{
Current.Logger.Warn<LocalizedTextServiceFileSources>("The folder does not exist: {0}, therefore no sources will be discovered", () => fileSourceFolder.FullName);
Current.Logger.Warn<LocalizedTextServiceFileSources>(() => $"The folder does not exist: {fileSourceFolder.FullName}, therefore no sources will be discovered");
}
else
{

View File

@@ -65,7 +65,7 @@ namespace Umbraco.Core.Sync
protected IScopeProvider ScopeProvider { get; }
protected Sql<ISqlContext> Sql() => _sqlContext.Sql();
private string DistCacheFilePath => _distCacheFilePath.Value;
#region Messenger
@@ -192,10 +192,9 @@ namespace Umbraco.Core.Sync
if (count > Options.MaxProcessingInstructionCount)
{
//too many instructions, proceed to cold boot
Logger.Warn<DatabaseServerMessenger>("The instruction count ({0}) exceeds the specified MaxProcessingInstructionCount ({1})."
Logger.Warn<DatabaseServerMessenger>(() => $"The instruction count ({count}) exceeds the specified MaxProcessingInstructionCount ({Options.MaxProcessingInstructionCount})."
+ " The server will skip existing instructions, rebuild its caches and indexes entirely, adjust its last synced Id"
+ " to the latest found in the database and maintain cache updates based on that Id.",
() => count, () => Options.MaxProcessingInstructionCount);
+ " to the latest found in the database and maintain cache updates based on that Id.");
coldboot = true;
}

View File

@@ -158,8 +158,7 @@ namespace Umbraco.Core.Sync
{
if (refresher == null) throw new ArgumentNullException(nameof(refresher));
Current.Logger.Debug<ServerMessengerBase>("Invoking refresher {0} on local server for message type RefreshByPayload",
refresher.GetType);
Current.Logger.Debug<ServerMessengerBase>(() => $"Invoking refresher {refresher.GetType()} on local server for message type RefreshByPayload");
var payloadRefresher = refresher as IPayloadCacheRefresher<TPayload>;
if (payloadRefresher == null)
@@ -181,9 +180,7 @@ namespace Umbraco.Core.Sync
{
if (refresher == null) throw new ArgumentNullException(nameof(refresher));
Current.Logger.Debug<ServerMessengerBase>("Invoking refresher {0} on local server for message type {1}",
refresher.GetType,
() => messageType);
Current.Logger.Debug<ServerMessengerBase>(() => $"Invoking refresher {refresher.GetType()} on local server for message type {messageType}");
switch (messageType)
{
@@ -244,9 +241,7 @@ namespace Umbraco.Core.Sync
{
if (refresher == null) throw new ArgumentNullException(nameof(refresher));
Current.Logger.Debug<ServerMessengerBase>("Invoking refresher {0} on local server for message type {1}",
refresher.GetType,
() => messageType);
Current.Logger.Debug<ServerMessengerBase>(() => $"Invoking refresher {refresher.GetType()} on local server for message type {messageType}");
var typedRefresher = refresher as ICacheRefresher<T>;

View File

@@ -160,13 +160,8 @@ namespace Umbraco.Core.Sync
Type idArrayType = null,
string jsonPayload = null)
{
Current.Logger.Debug<WebServiceServerMessenger>(
"Performing distributed call for {0}/{1} on servers ({2}), ids: {3}, json: {4}",
refresher.GetType,
() => messageType,
() => string.Join(";", servers.Select(x => x.ToString())),
() => ids == null ? "" : string.Join(";", ids.Select(x => x.ToString())),
() => jsonPayload ?? "");
Current.Logger.Debug<WebServiceServerMessenger>(() =>
$"Performing distributed call for {refresher.GetType()}/{messageType} on servers ({string.Join(";", servers.Select(x => x.ToString()))}), ids: {(ids == null ? "" : string.Join(";", ids.Select(x => x.ToString())))}, json: {(jsonPayload ?? "")}");
try
{

View File

@@ -56,7 +56,7 @@ namespace Umbraco.Examine
//This is using the config so we'll validate based on that
ValueSetValidator = new ValueSetValidatorDelegate(set =>
{
//check if this document is of a correct type of node type alias
if (ConfigIndexCriteria.IncludeItemTypes.Any())
if (!ConfigIndexCriteria.IncludeItemTypes.Contains(set.ItemType))
@@ -72,7 +72,7 @@ namespace Umbraco.Examine
}
protected UmbracoExamineIndexer(
string name,
string name,
IEnumerable<FieldDefinition> fieldDefinitions,
Directory luceneDirectory,
Analyzer defaultAnalyzer,
@@ -136,7 +136,7 @@ namespace Umbraco.Examine
/// When set to true Umbraco will keep the index in sync with Umbraco data automatically
/// </summary>
public bool EnableDefaultEventHandler { get; set; } = true;
/// <summary>
/// the supported indexable types
/// </summary>
@@ -162,7 +162,7 @@ namespace Umbraco.Examine
/// </remarks>
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
ProfilingLogger.Logger.Debug(GetType(), "{0} indexer initializing", () => name);
ProfilingLogger.Logger.Debug(GetType(), () => $"{name} indexer initializing");
if (config["enableDefaultEventHandler"] != null && bool.TryParse(config["enableDefaultEventHandler"], out var enabled))
{
@@ -337,7 +337,7 @@ namespace Umbraco.Examine
ProfilingLogger.Logger.Error(GetType(), e.Message, e.InnerException);
base.OnIndexingError(e);
}
/// <summary>
/// This ensures that the special __Raw_ fields are indexed
/// </summary>
@@ -359,20 +359,20 @@ namespace Umbraco.Examine
}
}
ProfilingLogger.Logger.Debug(GetType(), "Write lucene doc id:{0}, category:{1}, type:{2}", docArgs.ValueSet.Id, docArgs.ValueSet.Category, docArgs.ValueSet.ItemType);
ProfilingLogger.Logger.Debug(GetType(), () => $"Write lucene doc id:{docArgs.ValueSet.Id}, category:{docArgs.ValueSet.Category}, type:{docArgs.ValueSet.ItemType}");
base.OnDocumentWriting(docArgs);
}
/// <summary>
/// Overridden for logging.
/// </summary>
/// </summary>
protected override void AddDocument(Document doc, IndexItem item, IndexWriter writer)
{
ProfilingLogger.Logger.Debug(GetType(), "AddDocument {0} with type {1}", () => item.ValueSet.Id, () => item.ValueSet.ItemType);
ProfilingLogger.Logger.Debug(GetType(), () => $"AddDocument {item.ValueSet.Id} with type {item.ValueSet.ItemType}");
base.AddDocument(doc, item, writer);
}
protected override void OnTransformingIndexValues(IndexingItemEventArgs e)
{
base.OnTransformingIndexValues(e);

View File

@@ -405,22 +405,19 @@ namespace Umbraco.Web.Editors
if (lockedOut)
{
Logger.Info<AuthenticationController>(
"User {0} is currently locked out, unlocking and resetting AccessFailedCount",
() => model.UserId);
$"User {model.UserId} is currently locked out, unlocking and resetting AccessFailedCount");
//var user = await UserManager.FindByIdAsync(model.UserId);
var unlockResult = await UserManager.SetLockoutEndDateAsync(model.UserId, DateTimeOffset.Now);
if (unlockResult.Succeeded == false)
{
Logger.Warn<AuthenticationController>("Could not unlock for user {0} - error {1}",
() => model.UserId, () => unlockResult.Errors.First());
Logger.Warn<AuthenticationController>(() => $"Could not unlock for user {model.UserId} - error {unlockResult.Errors.First()}");
}
var resetAccessFailedCountResult = await UserManager.ResetAccessFailedCountAsync(model.UserId);
if (resetAccessFailedCountResult.Succeeded == false)
{
Logger.Warn<AuthenticationController>("Could not reset access failed count {0} - error {1}",
() => model.UserId, () => unlockResult.Errors.First());
Logger.Warn<AuthenticationController>(() => $"Could not reset access failed count {model.UserId} - error {unlockResult.Errors.First()}");
}
}
@@ -446,9 +443,7 @@ namespace Umbraco.Web.Editors
Core.Constants.Security.BackOfficeAuthenticationType,
Core.Constants.Security.BackOfficeExternalAuthenticationType);
Logger.Info<AuthenticationController>("User {0} from IP address {1} has logged out",
() => User.Identity == null ? "UNKNOWN" : User.Identity.Name,
() => owinContext.Request.RemoteIpAddress);
Logger.Info<AuthenticationController>($"User {(User.Identity == null ? "UNKNOWN" : User.Identity.Name)} from IP address {owinContext.Request.RemoteIpAddress} has logged out");
if (UserManager != null)
{

View File

@@ -185,10 +185,7 @@ namespace Umbraco.Web.Editors
var tryCreateTemplate = Services.FileService.CreateTemplateForContentType(ctSave.Alias, ctSave.Name);
if (tryCreateTemplate == false)
{
Logger.Warn<ContentTypeController>(
"Could not create a template for the Content Type: {0}, status: {1}",
() => ctSave.Alias,
() => tryCreateTemplate.Result.Result);
Logger.Warn<ContentTypeController>(() => $"Could not create a template for the Content Type: {ctSave.Alias}, status: {tryCreateTemplate.Result.Result}");
}
template = tryCreateTemplate.Result.Entity;
}

View File

@@ -194,7 +194,7 @@ namespace Umbraco.Web.Editors
var actionsXml = new XmlDocument();
actionsXml.LoadXml("<Actions>" + pack.Data.Actions + "</Actions>");
Logger.Debug<PackageInstallController>("executing undo actions: {0}", () => actionsXml.OuterXml);
Logger.Debug<PackageInstallController>(() => $"executing undo actions: {actionsXml.OuterXml}");
foreach (XmlNode n in actionsXml.DocumentElement.SelectNodes("//Action"))
{

View File

@@ -188,7 +188,7 @@ namespace Umbraco.Web.Editors
}
catch (Exception ex)
{
_logger.Warn<PasswordChanger>("Could not reset member password", ex);
_logger.Warn<PasswordChanger>(ex, "Could not reset member password");
return Attempt.Fail(new PasswordChangedModel { ChangeError = new ValidationResult("Could not reset password, error: " + ex.Message + " (see log for full details)", new[] { "resetPassword" }) });
}
}
@@ -213,7 +213,7 @@ namespace Umbraco.Web.Editors
}
catch (Exception ex)
{
_logger.Warn<PasswordChanger>("Could not change member password", ex);
_logger.Warn<PasswordChanger>(ex, "Could not change member password");
return Attempt.Fail(new PasswordChangedModel { ChangeError = new ValidationResult("Could not change password, error: " + ex.Message + " (see log for full details)", new[] { "value" }) });
}
}
@@ -242,7 +242,7 @@ namespace Umbraco.Web.Editors
}
catch (Exception ex)
{
_logger.Warn<PasswordChanger>("Could not change member password", ex);
_logger.Warn<PasswordChanger>(ex, "Could not change member password");
return Attempt.Fail(new PasswordChangedModel { ChangeError = new ValidationResult("Could not change password, error: " + ex.Message + " (see log for full details)", new[] { "value" }) });
}
}
@@ -274,14 +274,14 @@ namespace Umbraco.Web.Editors
}
catch (Exception ex1)
{
_logger.Warn<PasswordChanger>("Could not change member password", ex1);
_logger.Warn<PasswordChanger>(ex1, "Could not change member password");
return Attempt.Fail(new PasswordChangedModel { ChangeError = new ValidationResult("Could not change password, error: " + ex1.Message + " (see log for full details)", new[] { "value" }) });
}
}
catch (Exception ex2)
{
_logger.Warn<PasswordChanger>("Could not retrieve member password", ex2);
_logger.Warn<PasswordChanger>(ex2, "Could not retrieve member password");
return Attempt.Fail(new PasswordChangedModel { ChangeError = new ValidationResult("Could not change password, error: " + ex2.Message + " (see log for full details)", new[] { "value" }) });
}
}

View File

@@ -45,7 +45,7 @@ namespace Umbraco.Web.Install.InstallSteps
var dll = bin[0].GetFiles("Microsoft.Web.Mvc.FixedDisplayModes.dll", SearchOption.TopDirectoryOnly);
if (dll.Length == 1)
{
_logger.Info<Version73FileCleanup>("Deleting non-compatible and no longer used DLL: {0}", () => dll[0].FullName);
_logger.Info<Version73FileCleanup>($"Deleting non-compatible and no longer used DLL: {dll[0].FullName}");
File.Delete(dll[0].FullName);
}
}
@@ -70,7 +70,7 @@ namespace Umbraco.Web.Install.InstallSteps
foreach (var configFile in found)
{
var fileName = configFile.FullName;
_logger.Info<Version73FileCleanup>("Cleaning up web.config file: {0}", () => fileName);
_logger.Info<Version73FileCleanup>($"Cleaning up web.config file: {fileName}");
var contents = File.ReadAllText(fileName);
contents = _microsoftWebHelpers.Replace(contents, string.Empty);

View File

@@ -101,7 +101,7 @@ namespace Umbraco.Web.Macros
if (macroContent == null) return null;
Current.Logger.Debug<MacroRenderer>("Macro content loaded from cache \"{0}\".", () => model.CacheIdentifier);
Current.Logger.Debug<MacroRenderer>(() => $"Macro content loaded from cache \"{model.CacheIdentifier}\".");
// ensure that the source has not changed
// note: does not handle dependencies, and never has
@@ -166,7 +166,7 @@ namespace Umbraco.Web.Macros
priority: CacheItemPriority.NotRemovable
);
Current.Logger.Debug<MacroRenderer>("Macro content saved to cache \"{0}\".", () => model.CacheIdentifier);
Current.Logger.Debug<MacroRenderer>(() => $"Macro content saved to cache \"{model.CacheIdentifier}\".");
}
// gets the macro source file name

View File

@@ -38,7 +38,7 @@ namespace Umbraco.Web.Migrations
{
//backup
var targetPath = Path.Combine(tempCssFolder, relativePath.EnsureEndsWith(".bak"));
logger.Info<OverwriteStylesheetFilesFromTempFiles>("CSS file is being backed up from {0}, to {1} before being migrated to new format", () => cssFilePath, () => targetPath);
logger.Info<OverwriteStylesheetFilesFromTempFiles>($"CSS file is being backed up from {cssFilePath}, to {targetPath} before being migrated to new format");
File.Copy(cssFilePath, targetPath, true);
}

View File

@@ -319,12 +319,8 @@ namespace Umbraco.Web.Mvc
}
else
{
Current.Logger.Warn<RenderRouteHandler>(
"The current Document Type {0} matches a locally declared controller of type {1}. Custom Controllers for Umbraco routing must implement '{2}' and inherit from '{3}'.",
() => request.PublishedContent.DocumentTypeAlias,
() => controllerType.FullName,
() => typeof(IRenderController).FullName,
() => typeof(ControllerBase).FullName);
Current.Logger.Warn<RenderRouteHandler>(() =>
$"The current Document Type {request.PublishedContent.DocumentTypeAlias} matches a locally declared controller of type {controllerType.FullName}. Custom Controllers for Umbraco routing must implement '{typeof(IRenderController).FullName}' and inherit from '{typeof(ControllerBase).FullName}'.");
//we cannot route to this custom controller since it is not of the correct type so we'll continue with the defaults
// that have already been set above.

View File

@@ -70,7 +70,7 @@ namespace Umbraco.Web.PublishedCache
/// <param name="id">An identifier.</param>
public void ClearContentType(int id)
{
_logger.Debug<PublishedContentTypeCache>("Clear content type w/id {0}.", () => id);
_logger.Debug<PublishedContentTypeCache>(() => $"Clear content type w/id {id}.");
try
{
@@ -105,7 +105,7 @@ namespace Umbraco.Web.PublishedCache
/// <param name="id">A data type identifier.</param>
public void ClearDataType(int id)
{
_logger.Debug<PublishedContentTypeCache>("Clear data type w/id {0}.", () => id);
_logger.Debug<PublishedContentTypeCache>(() => $"Clear data type w/id {id}.");
// there is no recursion to handle here because a PublishedContentType contains *all* its
// properties ie both its own properties and those that were inherited (it's based upon an

View File

@@ -232,7 +232,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
return null;
}
}
private ISearcher GetSearchProviderSafe()
{
if (_searchProvider != null)
@@ -333,9 +333,8 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
var miss = Interlocked.CompareExchange(ref _examineIndexMiss, 0, 0); // volatile read
if (miss < ExamineIndexMissMax && Interlocked.Increment(ref _examineIndexMiss) == ExamineIndexMissMax)
Current.Logger.Warn<PublishedMediaCache>("Failed ({0} times) to retrieve medias from Examine index and had to load"
+ " them from DB. This may indicate that the Examine index is corrupted.",
() => ExamineIndexMissMax);
Current.Logger.Warn<PublishedMediaCache>(() => $"Failed ({ExamineIndexMissMax} times) to retrieve medias from Examine index and had to load"
+ " them from DB. This may indicate that the Examine index is corrupted.");
return ConvertFromIMedia(media);
}
@@ -352,9 +351,8 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
: ConvertFromXPathNavigator(media.Current);
}
Current.Logger.Warn<PublishedMediaCache>(
"Could not retrieve media {0} from Examine index or from legacy library.GetMedia method",
() => id);
Current.Logger.Warn<PublishedMediaCache>(() =>
$"Could not retrieve media {id} from Examine index or from legacy library.GetMedia method");
return null;
}
@@ -362,7 +360,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
internal CacheValues ConvertFromSearchResult(SearchResult searchResult)
{
// note: fixing fields in 7.x, removed by Shan for 8.0
return new CacheValues
{
Values = searchResult.Fields,

View File

@@ -62,7 +62,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
if (touched == false) return;
_logger.Debug<XmlStoreFilePersister>("Created, save in {0}ms.", () => WaitMilliseconds);
_logger.Debug<XmlStoreFilePersister>(() => $"Created, save in {WaitMilliseconds}ms.");
_initialTouch = DateTime.Now;
_timer = new Timer(_ => TimerRelease());
_timer.Change(WaitMilliseconds, 0);
@@ -107,7 +107,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
else if (_timer == null) // we don't have a timer yet
{
_logger.Debug<XmlStoreFilePersister>("Touched, was idle, start and save in {0}ms.", () => WaitMilliseconds);
_logger.Debug<XmlStoreFilePersister>(() => $"Touched, was idle, start and save in {WaitMilliseconds}ms.");
_initialTouch = DateTime.Now;
_timer = new Timer(_ => TimerRelease());
_timer.Change(WaitMilliseconds, 0);
@@ -120,7 +120,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
if (DateTime.Now - _initialTouch < TimeSpan.FromMilliseconds(MaxWaitMilliseconds))
{
_logger.Debug<XmlStoreFilePersister>("Touched, was waiting, can delay, save in {0}ms.", () => WaitMilliseconds);
_logger.Debug<XmlStoreFilePersister>(() => $"Touched, was waiting, can delay, save in {WaitMilliseconds}ms.");
_timer.Change(WaitMilliseconds, 0);
}
else

View File

@@ -53,13 +53,13 @@ namespace Umbraco.Web.Routing
if (nodeId > 0)
{
_logger.Debug<ContentFinderByIdPath>("Id={0}", () => nodeId);
_logger.Debug<ContentFinderByIdPath>(() => $"Id={nodeId}");
node = frequest.UmbracoContext.ContentCache.GetById(nodeId);
if (node != null)
{
frequest.PublishedContent = node;
_logger.Debug<ContentFinderByIdPath>("Found node with id={0}", () => frequest.PublishedContent.Id);
_logger.Debug<ContentFinderByIdPath>(() => $"Found node with id={frequest.PublishedContent.Id}");
}
else
{

View File

@@ -70,7 +70,7 @@ namespace Umbraco.Web.Routing
if (error404.HasValue)
{
_logger.Debug<ContentFinderByLegacy404>("Got id={0}.", () => error404.Value);
_logger.Debug<ContentFinderByLegacy404>(() => $"Got id={error404.Value}.");
content = frequest.UmbracoContext.ContentCache.GetById(error404.Value);

View File

@@ -44,13 +44,13 @@ namespace Umbraco.Web.Routing
/// <returns>The document node, or null.</returns>
protected IPublishedContent FindContent(PublishedRequest docreq, string route)
{
Logger.Debug<ContentFinderByNiceUrl>("Test route \"{0}\"", () => route);
Logger.Debug<ContentFinderByNiceUrl>(() => $"Test route \"{route}\"");
var node = docreq.UmbracoContext.ContentCache.GetByRoute(route);
if (node != null)
{
docreq.PublishedContent = node;
Logger.Debug<ContentFinderByNiceUrl>("Got content, id={0}", () => node.Id);
Logger.Debug<ContentFinderByNiceUrl>(() => $"Got content, id={node.Id}");
}
else
{

View File

@@ -43,7 +43,7 @@ namespace Umbraco.Web.Routing
var template = Current.Services.FileService.GetTemplate(templateAlias);
if (template != null)
{
Logger.Debug<ContentFinderByNiceUrlAndTemplate>("Valid template: \"{0}\"", () => templateAlias);
Logger.Debug<ContentFinderByNiceUrlAndTemplate>(() => $"Valid template: \"{templateAlias}\"");
var route = frequest.HasDomain ? (frequest.Domain.ContentId.ToString() + path) : path;
node = FindContent(frequest, route);
@@ -53,7 +53,7 @@ namespace Umbraco.Web.Routing
}
else
{
Logger.Debug<ContentFinderByNiceUrlAndTemplate>("Not a valid template: \"{0}\"", () => templateAlias);
Logger.Debug<ContentFinderByNiceUrlAndTemplate>(() => $"Not a valid template: \"{templateAlias}\"");
}
}
else

View File

@@ -39,7 +39,7 @@ namespace Umbraco.Web.Routing
if (path == GlobalSettings.ProfileUrl)
{
isProfile = true;
Logger.Debug<ContentFinderByProfile>("Path \"{0}\" is the profile path", () => path);
Logger.Debug<ContentFinderByProfile>(() => $"Path \"{path}\" is the profile path");
var route = frequest.HasDomain ? (frequest.Domain.ContentId + path) : path;
node = FindContent(frequest, route);

View File

@@ -48,7 +48,7 @@ namespace Umbraco.Web.Routing
if (redirectUrl == null)
{
_logger.Debug<ContentFinderByRedirectUrl>("No match for route: \"{0}\".", () => route);
_logger.Debug<ContentFinderByRedirectUrl>(() => $"No match for route: \"{route}\".");
return false;
}
@@ -56,13 +56,11 @@ namespace Umbraco.Web.Routing
var url = content == null ? "#" : content.Url;
if (url.StartsWith("#"))
{
_logger.Debug<ContentFinderByRedirectUrl>("Route \"{0}\" matches content {1} which has no url.",
() => route, () => redirectUrl.ContentId);
_logger.Debug<ContentFinderByRedirectUrl>(() => $"Route \"{route}\" matches content {redirectUrl.ContentId} which has no url.");
return false;
}
_logger.Debug<ContentFinderByRedirectUrl>("Route \"{0}\" matches content {1} with url \"{2}\", redirecting.",
() => route, () => content.Id, () => url);
_logger.Debug<ContentFinderByRedirectUrl>(() => $"Route \"{route}\" matches content {content.Id} with url \"{url}\", redirecting.");
frequest.SetRedirectPermanent(url);
return true;
}

View File

@@ -43,7 +43,7 @@ namespace Umbraco.Web.Routing
if (node != null)
{
frequest.PublishedContent = node;
Logger.Debug<ContentFinderByUrlAlias>("Path \"{0}\" is an alias for id={1}", () => frequest.Uri.AbsolutePath, () => frequest.PublishedContent.Id);
Logger.Debug<ContentFinderByUrlAlias>(() => $"Path \"{frequest.Uri.AbsolutePath}\" is an alias for id={frequest.PublishedContent.Id}");
}
}

View File

@@ -49,9 +49,8 @@ namespace Umbraco.Web.Routing
{
if (string.IsNullOrWhiteSpace(route))
{
_logger.Debug<DefaultUrlProvider>(
"Couldn't find any page with nodeId={0}. This is most likely caused by the page not being published.",
() => id);
_logger.Debug<DefaultUrlProvider>(() =>
$"Couldn't find any page with nodeId={id}. This is most likely caused by the page not being published.");
return null;
}
@@ -91,9 +90,8 @@ namespace Umbraco.Web.Routing
if (string.IsNullOrWhiteSpace(route))
{
_logger.Debug<DefaultUrlProvider>(
"Couldn't find any page with nodeId={0}. This is most likely caused by the page not being published.",
() => id);
_logger.Debug<DefaultUrlProvider>(() =>
$"Couldn't find any page with nodeId={id}. This is most likely caused by the page not being published.");
return null;
}

View File

@@ -263,7 +263,7 @@ namespace Umbraco.Web.Routing
// note - we are not handling schemes nor ports here.
_logger.Debug<PublishedRouter>("{0}Uri=\"{1}\"", () => tracePrefix, () => request.Uri);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Uri=\"{request.Uri}\"");
// try to find a domain matching the current request
var domainAndUri = DomainHelper.DomainForUri(request.UmbracoContext.PublishedShapshot.Domains.GetAll(false), request.Uri);
@@ -272,11 +272,7 @@ namespace Umbraco.Web.Routing
if (domainAndUri != null)
{
// matching an existing domain
_logger.Debug<PublishedRouter>("{0}Matches domain=\"{1}\", rootId={2}, culture=\"{3}\"",
() => tracePrefix,
() => domainAndUri.Name,
() => domainAndUri.ContentId,
() => domainAndUri.Culture);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Matches domain=\"{domainAndUri.Name}\", rootId={domainAndUri.ContentId}, culture=\"{domainAndUri.Culture}\"");
request.Domain = domainAndUri;
request.Culture = domainAndUri.Culture;
@@ -291,13 +287,13 @@ namespace Umbraco.Web.Routing
else
{
// not matching any existing domain
_logger.Debug<PublishedRouter>("{0}Matches no domain", () => tracePrefix);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Matches no domain");
var defaultLanguage = _services.LocalizationService.GetAllLanguages().FirstOrDefault();
request.Culture = defaultLanguage == null ? CultureInfo.CurrentUICulture : new CultureInfo(defaultLanguage.IsoCode);
}
_logger.Debug<PublishedRouter>("{0}Culture=\"{1}\"", () => tracePrefix, () => request.Culture.Name);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Culture=\"{request.Culture.Name}\"");
return request.Domain != null;
}
@@ -313,7 +309,7 @@ namespace Umbraco.Web.Routing
return;
var nodePath = request.PublishedContent.Path;
_logger.Debug<PublishedRouter>("{0}Path=\"{1}\"", () => tracePrefix, () => nodePath);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Path=\"{nodePath}\"");
var rootNodeId = request.HasDomain ? request.Domain.ContentId : (int?)null;
var domain = DomainHelper.FindWildcardDomainInPath(request.UmbracoContext.PublishedShapshot.Domains.GetAll(true), nodePath, rootNodeId);
@@ -321,12 +317,11 @@ namespace Umbraco.Web.Routing
if (domain != null)
{
request.Culture = domain.Culture;
_logger.Debug<PublishedRouter>("{0}Got domain on node {1}, set culture to \"{2}\".", () => tracePrefix,
() => domain.ContentId, () => request.Culture.Name);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Got domain on node {domain.ContentId}, set culture to \"{request.Culture.Name}\".");
}
else
{
_logger.Debug<PublishedRouter>("{0}No match.", () => tracePrefix);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}No match.");
}
}
@@ -400,7 +395,7 @@ namespace Umbraco.Web.Routing
private void FindPublishedContentAndTemplate(PublishedRequest request)
{
const string tracePrefix = "FindPublishedContentAndTemplate: ";
_logger.Debug<PublishedRouter>("{0}Path=\"{1}\"", () => tracePrefix, () => request.Uri.AbsolutePath);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Path=\"{request.Uri.AbsolutePath}\"");
// run the document finders
FindPublishedContent(request);
@@ -469,22 +464,22 @@ namespace Umbraco.Web.Routing
const int maxLoop = 8;
do
{
_logger.Debug<PublishedRouter>("{0}{1}", () => tracePrefix, () => (i == 0 ? "Begin" : "Loop"));
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}{(i == 0 ? "Begin" : "Loop")}");
// handle not found
if (request.HasPublishedContent == false)
{
request.Is404 = true;
_logger.Debug<PublishedRouter>("{0}No document, try last chance lookup", () => tracePrefix);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}No document, try last chance lookup");
// if it fails then give up, there isn't much more that we can do
if (_contentLastChanceFinder.TryFindContent(request) == false)
{
_logger.Debug<PublishedRouter>("{0}Failed to find a document, give up", () => tracePrefix);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Failed to find a document, give up");
break;
}
_logger.Debug<PublishedRouter>("{0}Found a document", () => tracePrefix);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Found a document");
}
// follow internal redirects as long as it's not running out of control ie infinite loop of some sort
@@ -506,11 +501,11 @@ namespace Umbraco.Web.Routing
if (i == maxLoop || j == maxLoop)
{
_logger.Debug<PublishedRouter>("{0}Looks like we're running into an infinite loop, abort", () => tracePrefix);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Looks like we're running into an infinite loop, abort");
request.PublishedContent = null;
}
_logger.Debug<PublishedRouter>("{0}End", () => tracePrefix);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}End");
}
/// <summary>
@@ -596,13 +591,13 @@ namespace Umbraco.Web.Routing
if (publicAccessAttempt)
{
_logger.Debug<PublishedRouter>("{0}Page is protected, check for access", () => tracePrefix);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Page is protected, check for access");
var membershipHelper = new MembershipHelper(request.UmbracoContext);
if (membershipHelper.IsLoggedIn() == false)
{
_logger.Debug<PublishedRouter>("{0}Not logged in, redirect to login page", () => tracePrefix);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Not logged in, redirect to login page");
var loginPageId = publicAccessAttempt.Result.LoginNodeId;
@@ -611,19 +606,19 @@ namespace Umbraco.Web.Routing
}
else if (_services.PublicAccessService.HasAccess(request.PublishedContent.Id, _services.ContentService, GetRolesForLogin(membershipHelper.CurrentUserName)) == false)
{
_logger.Debug<PublishedRouter>("{0}Current member has not access, redirect to error page", () => tracePrefix);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Current member has not access, redirect to error page");
var errorPageId = publicAccessAttempt.Result.NoAccessNodeId;
if (errorPageId != request.PublishedContent.Id)
request.PublishedContent = request.UmbracoContext.PublishedShapshot.Content.GetById(errorPageId);
}
else
{
_logger.Debug<PublishedRouter>("{0}Current member has access", () => tracePrefix);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Current member has access");
}
}
else
{
_logger.Debug<PublishedRouter>("{0}Page is not protected", () => tracePrefix);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Page is not protected");
}
}
@@ -663,7 +658,7 @@ namespace Umbraco.Web.Routing
if (request.HasTemplate)
{
_logger.Debug<PublishedRequest>("{0}Has a template already, and no alternate template.", () => tracePrefix);
_logger.Debug<PublishedRequest>("{0}Has a template already, and no alternate template.");
return;
}
@@ -674,16 +669,16 @@ namespace Umbraco.Web.Routing
if (templateId > 0)
{
_logger.Debug<PublishedRouter>("{0}Look for template id={1}", () => tracePrefix, () => templateId);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Look for template id={templateId}");
var template = _services.FileService.GetTemplate(templateId);
if (template == null)
throw new InvalidOperationException("The template with Id " + templateId + " does not exist, the page cannot render");
request.TemplateModel = template;
_logger.Debug<PublishedRouter>("{0}Got template id={1} alias=\"{2}\"", () => tracePrefix, () => template.Id, () => template.Alias);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Got template id={template.Id} alias=\"{template.Alias}\"");
}
else
{
_logger.Debug<PublishedRouter>("{0}No specified template.", () => tracePrefix);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}No specified template.");
}
}
else
@@ -695,24 +690,24 @@ namespace Umbraco.Web.Routing
// ignore if the alias does not match - just trace
if (request.HasTemplate)
_logger.Debug<PublishedRouter>("{0}Has a template already, but also an alternate template.", () => tracePrefix);
_logger.Debug<PublishedRouter>("{0}Look for alternate template alias=\"{1}\"", () => tracePrefix, () => altTemplate);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Has a template already, but also an alternate template.");
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Look for alternate template alias=\"{altTemplate}\"");
var template = _services.FileService.GetTemplate(altTemplate);
if (template != null)
{
request.TemplateModel = template;
_logger.Debug<PublishedRouter>("{0}Got template id={1} alias=\"{2}\"", () => tracePrefix, () => template.Id, () => template.Alias);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Got template id={template.Id} alias=\"{template.Alias}\"");
}
else
{
_logger.Debug<PublishedRouter>("{0}The template with alias=\"{1}\" does not exist, ignoring.", () => tracePrefix, () => altTemplate);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}The template with alias=\"{altTemplate}\" does not exist, ignoring.");
}
}
if (request.HasTemplate == false)
{
_logger.Debug<PublishedRouter>("{0}No template was found.", () => tracePrefix);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}No template was found.");
// initial idea was: if we're not already 404 and UmbracoSettings.HandleMissingTemplateAs404 is true
// then reset _pcr.Document to null to force a 404.
@@ -725,7 +720,7 @@ namespace Umbraco.Web.Routing
}
else
{
_logger.Debug<PublishedRouter>("{0}Running with template id={1} alias=\"{2}\"", () => tracePrefix, () => request.TemplateModel.Id, () => request.TemplateModel.Alias);
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Running with template id={request.TemplateModel.Id} alias=\"{request.TemplateModel.Alias}\"");
}
}

View File

@@ -233,7 +233,7 @@ namespace Umbraco.Web.Scheduling
throw new InvalidOperationException("The task runner has completed.");
// add task
_logger.Debug<BackgroundTaskRunner>(_logPrefix + "Task added {0}", () => task.GetType().FullName);
_logger.Debug<BackgroundTaskRunner>(() => _logPrefix + "Task added " + task.GetType().FullName);
_tasks.Post(task);
// start
@@ -253,12 +253,12 @@ namespace Umbraco.Web.Scheduling
{
if (_completed)
{
_logger.Debug<BackgroundTaskRunner>(_logPrefix + "Task cannot be added {0}, the task runner has already shutdown", () => task.GetType().FullName);
_logger.Debug<BackgroundTaskRunner>(() => _logPrefix + $"Task cannot be added {task.GetType().FullName}, the task runner has already shutdown");
return false;
}
// add task
_logger.Debug<BackgroundTaskRunner>(_logPrefix + "Task added {0}", () => task.GetType().FullName);
_logger.Debug<BackgroundTaskRunner>(() => _logPrefix + "Task added " + task.GetType().FullName);
_tasks.Post(task);
// start

View File

@@ -341,9 +341,7 @@ namespace Umbraco.Web
var end = false;
var response = context.Response;
logger.Debug<UmbracoModule>("Response status: Redirect={0}, Is404={1}, StatusCode={2}",
() => pcr.IsRedirect ? (pcr.IsRedirectPermanent ? "permanent" : "redirect") : "none",
() => pcr.Is404 ? "true" : "false", () => pcr.ResponseStatusCode);
logger.Debug<UmbracoModule>(() => $"Response status: Redirect={(pcr.IsRedirect ? (pcr.IsRedirectPermanent ? "permanent" : "redirect") : "none")}, Is404={(pcr.Is404 ? "true" : "false")}, StatusCode={pcr.ResponseStatusCode}");
if(pcr.Cacheability != default(HttpCacheability))
response.Cache.SetCacheability(pcr.Cacheability);
@@ -540,7 +538,7 @@ namespace Umbraco.Web
app.BeginRequest += (sender, e) =>
{
var httpContext = ((HttpApplication) sender).Context;
Logger.Debug<UmbracoModule>("Begin request: {0}.", () => httpContext.Request.Url);
Logger.Debug<UmbracoModule>(() => $"Begin request: {httpContext.Request.Url}.");
BeginRequest(new HttpContextWrapper(httpContext));
};

View File

@@ -275,7 +275,7 @@ namespace umbraco
Current.Logger.Error<library>("An error occurred looking up media", ex);
}
Current.Logger.Debug<library>("No media result for id {0}", () => MediaId);
Current.Logger.Debug<library>(() => $"No media result for id {MediaId}");
var errorXml = new XElement("error", string.Format("No media is maching '{0}'", MediaId));
return errorXml.CreateNavigator().Select("/");
@@ -331,7 +331,7 @@ namespace umbraco
Current.Logger.Error<library>("An error occurred looking up member", ex);
}
Current.Logger.Debug<library>("No member result for id {0}", () => MemberId);
Current.Logger.Debug<library>(() => $"No member result for id {MemberId}");
var xd = new XmlDocument();
xd.LoadXml(string.Format("<error>No member is maching '{0}'</error>", MemberId));

View File

@@ -34,11 +34,8 @@ namespace umbraco.presentation.webservices
if (string.IsNullOrEmpty(hash)) return false; // no hash = don't know = not self
if (hash != WebServiceServerMessenger.GetCurrentServerHash()) return false;
Current.Logger.Debug<CacheRefresher>(
"Ignoring self-message. (server: {0}, appId: {1}, hash: {2})",
() => NetworkHelper.MachineName,
() => HttpRuntime.AppDomainAppId,
() => hash);
Current.Logger.Debug<CacheRefresher>(() =>
$"Ignoring self-message. (server: {NetworkHelper.MachineName}, appId: {HttpRuntime.AppDomainAppId}, hash: {hash})");
return true;
}