FIRST PASS - Updates Umbraco.Web project to not use the func overload & to use new message template instead

This commit is contained in:
Warren
2018-08-14 22:36:47 +01:00
parent 2a298aaaf5
commit 23ed9773bc
35 changed files with 159 additions and 152 deletions

View File

@@ -406,20 +406,19 @@ namespace Umbraco.Web.Editors
var lockedOut = await UserManager.IsLockedOutAsync(model.UserId);
if (lockedOut)
{
Logger.Info<AuthenticationController>(() =>
$"User {model.UserId} is currently locked out, unlocking and resetting AccessFailedCount");
Logger.Info<AuthenticationController>("User {UserId} is currently locked out, unlocking and resetting AccessFailedCount", model.UserId);
//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 {model.UserId} - error {unlockResult.Errors.First()}");
Logger.Warn<AuthenticationController>("Could not unlock for user {UserId} - error {UnlockError}", model.UserId, unlockResult.Errors.First());
}
var resetAccessFailedCountResult = await UserManager.ResetAccessFailedCountAsync(model.UserId);
if (resetAccessFailedCountResult.Succeeded == false)
{
Logger.Warn<AuthenticationController>(() => $"Could not reset access failed count {model.UserId} - error {unlockResult.Errors.First()}");
Logger.Warn<AuthenticationController>("Could not reset access failed count {UserId} - error {UnlockError}", model.UserId, unlockResult.Errors.First());
}
}
@@ -445,7 +444,7 @@ namespace Umbraco.Web.Editors
Core.Constants.Security.BackOfficeAuthenticationType,
Core.Constants.Security.BackOfficeExternalAuthenticationType);
Logger.Info<AuthenticationController>(() => $"User {(User.Identity == null ? "UNKNOWN" : User.Identity.Name)} from IP address {owinContext.Request.RemoteIpAddress} has logged out");
Logger.Info<AuthenticationController>("User {UserName} from IP address {RemoteIpAddress} has logged out", User.Identity == null ? "UNKNOWN" : User.Identity.Name, owinContext.Request.RemoteIpAddress);
if (UserManager != null)
{

View File

@@ -278,7 +278,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: {ctSave.Alias}, status: {tryCreateTemplate.Result.Result}");
Logger.Warn<ContentTypeController>("Could not create a template for the Content Type: {ContentTypeAlias}, status: {CreateTemplateResult}", ctSave.Alias, tryCreateTemplate.Result.Result);
}
template = tryCreateTemplate.Result.Entity;
}

View File

@@ -66,7 +66,7 @@ namespace Umbraco.Web.Editors
}
catch (HttpRequestException ex)
{
Logger.Debug<DashboardController>(() => $"Error getting dashboard content from '{url}': {ex.Message}\n{ex.InnerException}");
Logger.Error<DashboardController>("Error getting dashboard content from '{Url}'", ex.InnerException ?? ex, url);
//it's still new JObject() - we return it like this to avoid error codes which triggers UI warnings
ApplicationCache.RuntimeCache.InsertCacheItem<JObject>(key, () => result, new TimeSpan(0, 5, 0));
@@ -107,7 +107,7 @@ namespace Umbraco.Web.Editors
}
catch (HttpRequestException ex)
{
Logger.Debug<DashboardController>(() => string.Format("Error getting dashboard CSS from '{0}': {1}\n{2}", url, ex.Message, ex.InnerException));
Logger.Error<DashboardController>("Error getting dashboard CSS from '{Url}'", ex.InnerException ?? ex, url);
//it's still string.Empty - we return it like this to avoid error codes which triggers UI warnings
ApplicationCache.RuntimeCache.InsertCacheItem<string>(key, () => result, new TimeSpan(0, 5, 0));

View File

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

View File

@@ -93,7 +93,7 @@ namespace Umbraco.Web.Editors
if (resetResult.Succeeded == false)
{
var errors = string.Join(". ", resetResult.Errors);
_logger.Warn<PasswordChanger>(() => $"Could not reset user password {errors}");
_logger.Warn<PasswordChanger>("Could not reset user password {PasswordErrors}", errors);
return Attempt.Fail(new PasswordChangedModel { ChangeError = new ValidationResult("Could not reset password, errors: " + errors, new[] { "resetPassword" }) });
}
@@ -122,7 +122,7 @@ namespace Umbraco.Web.Editors
if (changeResult.Succeeded == false)
{
var errors = string.Join(". ", changeResult.Errors);
_logger.Warn<PasswordChanger>(() => $"Could not change user password {errors}");
_logger.Warn<PasswordChanger>("Could not change user password {PasswordErrors}", errors);
return Attempt.Fail(new PasswordChangedModel { ChangeError = new ValidationResult("Could not change password, errors: " + errors, new[] { "oldPassword" }) });
}
return Attempt.Succeed(new PasswordChangedModel());

View File

@@ -62,16 +62,16 @@ namespace Umbraco.Web.HealthCheck
var checkIsSuccess = result.Value.All(x => x.ResultType == StatusResultType.Success);
if (checkIsSuccess)
{
Logger.Info<HealthCheckResults>(() => $" Checks for '{checkName}' all completed succesfully.");
Logger.Info<HealthCheckResults>("Checks for '{HealthCheckName}' all completed succesfully.", checkName);
}
else
{
Logger.Warn<HealthCheckResults>(() => $" Checks for '{checkName}' completed with errors.");
Logger.Warn<HealthCheckResults>("Checks for '{HealthCheckName}' completed with errors.", checkName);
}
foreach (var checkResult in checkResults)
{
Logger.Info<HealthCheckResults>(() => $" Result: {checkResult.ResultType}, Message: '{checkResult.Message}'");
Logger.Info<HealthCheckResults>("Result for {HealthCheckName}: {HealthCheckResult}, Message: '{HealthCheckMessage}'", checkName, checkResult.ResultType, checkResult.Message);
}
}
}

View File

@@ -99,7 +99,7 @@ namespace Umbraco.Web.Macros
if (macroContent == null) return null;
Current.Logger.Debug<MacroRenderer>(() => $"Macro content loaded from cache \"{model.CacheIdentifier}\".");
Current.Logger.Debug<MacroRenderer>("Macro content loaded from cache '{MacroCacheId}'", model.CacheIdentifier);
// ensure that the source has not changed
// note: does not handle dependencies, and never has
@@ -159,7 +159,7 @@ namespace Umbraco.Web.Macros
priority: CacheItemPriority.NotRemovable
);
Current.Logger.Debug<MacroRenderer>(() => $"Macro content saved to cache \"{model.CacheIdentifier}\".");
Current.Logger.Debug<MacroRenderer>("Macro content saved to cache '{MacroCacheId}'", model.CacheIdentifier);
}
// gets the macro source file name
@@ -304,7 +304,7 @@ namespace Umbraco.Web.Macros
{
Exceptions.Add(e);
_plogger.Logger.Warn<MacroRenderer>(e, () => $"Failed {msgIn}");
_plogger.Logger.Warn<MacroRenderer>(e, "Failed {MsgIn}", msgIn);
var macroErrorEventArgs = new MacroErrorEventArgs
{

View File

@@ -31,7 +31,7 @@ namespace Umbraco.Web.Macros
// note: we are not setting the 'CurrentNode' property on the control anymore,
// as that was an INode which is gone in v8. Use UmbracoContext to access the
// current content.
Current.Logger.Info<UserControlMacroEngine>(() => $"Loaded control \"{filename}\" with ID \"{control.ID}\".");
Current.Logger.Info<UserControlMacroEngine>("Loaded control '{UserControlFile}' with ID '{UserControlId}'", filename, control.ID);
UpdateControlProperties(control, model);
return new MacroContent { Control = control };
@@ -64,7 +64,7 @@ namespace Umbraco.Web.Macros
var controlProperty = type.GetProperty(modelProperty.Key);
if (controlProperty == null)
{
Current.Logger.Warn<UserControlMacroEngine>(() => $"Control property \"{modelProperty.Key}\" doesn't exist or isn't accessible, skip.");
Current.Logger.Warn<UserControlMacroEngine>("Control property '{UserControlProperty}' doesn't exist or isn't accessible, skip.", modelProperty.Key);
continue;
}
@@ -74,16 +74,16 @@ namespace Umbraco.Web.Macros
try
{
controlProperty.SetValue(control, tryConvert.Result, null);
Current.Logger.Debug<UserControlMacroEngine>(() => $"Set property \"{modelProperty.Key}\" value \"{modelProperty.Value}\".");
Current.Logger.Debug<UserControlMacroEngine>("Set property '{UserControlProperty}' value '{UserControlPropertyValue}'", modelProperty.Key, modelProperty.Value);
}
catch (Exception e)
{
Current.Logger.Warn<UserControlMacroEngine>(e, () => $"Failed to set property \"{modelProperty.Key}\" value \"{modelProperty.Value}\".");
Current.Logger.Warn<UserControlMacroEngine>(e, "Failed to set property '{UserControlProperty}' value '{UserControlPropertyValue}'", modelProperty.Key, modelProperty.Value);
}
}
else
{
Current.Logger.Warn<UserControlMacroEngine>(() => $"Failed to set property \"{modelProperty.Key}\" value \"{modelProperty.Value}\".");
Current.Logger.Warn<UserControlMacroEngine>("Failed to set property '{UserControlProperty}' value '{UserControlPropertyValue}'", modelProperty.Key, modelProperty.Value);
}
}
}

View File

@@ -25,7 +25,7 @@ namespace Umbraco.Web.Models.Mapping
if (configuration.TryGetValue(field.Key, out var value))
field.Value = value;
else // weird - just leave the field without a value - but warn
Current.Logger.Warn<DataTypeConfigurationFieldDisplayResolver>(() => $"Could not find a value for configuration field \"{field.Key}\".");
Current.Logger.Warn<DataTypeConfigurationFieldDisplayResolver>("Could not find a value for configuration field '{ConfigField}'", field.Key);
}
}

View File

@@ -41,7 +41,7 @@ namespace Umbraco.Web.Models.Mapping
{
//we'll just map this to a text box
paramEditor = Current.ParameterEditors[Constants.PropertyEditors.Aliases.TextBox];
Current.Logger.Warn<MacroMapperProfile>(() => $"Could not resolve a parameter editor with alias {property.EditorAlias}, a textbox will be rendered in it's place");
Current.Logger.Warn<MacroMapperProfile>("Could not resolve a parameter editor with alias {PropertyEditorAlias}, a textbox will be rendered in it's place", property.EditorAlias);
}
parameter.View = paramEditor.GetValueEditor().View;

View File

@@ -319,8 +319,11 @@ namespace Umbraco.Web.Mvc
}
else
{
Current.Logger.Warn<RenderRouteHandler>(() =>
$"The current Document Type {request.PublishedContent.ContentType.Alias} 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}'.");
Current.Logger.Warn<RenderRouteHandler>("The current Document Type {ContentTypeAlias} matches a locally declared controller of type {ControllerName}. Custom Controllers for Umbraco routing must implement '{UmbracoRenderController}' and inherit from '{UmbracoControllerBase}'.",
request.PublishedContent.ContentType.Alias,
controllerType.FullName,
typeof(IRenderController).FullName,
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

@@ -95,7 +95,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
}
else
{
_logger.Warn<RelatedLinksValueConverter>(() => $"Related Links value converter skipped a link as the node has been unpublished/deleted (Internal Link NodeId: {relatedLink.Link}, Link Caption: \"{relatedLink.Caption}\")");
_logger.Warn<RelatedLinksValueConverter>("Related Links value converter skipped a link as the node has been unpublished/deleted (Internal Link NodeId: {RelatedLinkNodeId}, Link Caption: '{RelatedLinkCaption}')", relatedLink.Link, relatedLink.Caption);
}
}
@@ -158,7 +158,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
}
catch (Exception ex)
{
_logger.Error<RelatedLinksValueConverter>("Could not parse the string " + sourceString + " to a json object", ex);
_logger.Error<RelatedLinksValueConverter>("Could not parse the string {SourceString} to a json object", ex, sourceString);
}
}

View File

@@ -446,7 +446,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
throw new ArgumentException("Kit content cannot have children.", nameof(kit));
// ReSharper restore LocalizableElement
_logger.Debug<ContentStore>(() => "Set content ID:" + kit.Node.Id);
_logger.Debug<ContentStore>("Set content ID: {KitNodeId}", kit.Node.Id);
var lockInfo = new WriteLockInfo();
try
@@ -571,7 +571,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
if (link?.Value == null) return false;
var content = link.Value;
_logger.Debug<ContentStore>(() => "Clear content ID:" + content.Id);
_logger.Debug<ContentStore>("Clear content ID: {ContentId}", content.Id);
// clear the entire branch
ClearBranchLocked(content);
@@ -921,7 +921,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
{
// see notes in CreateSnapshot
#if DEBUG
_logger.Debug<ContentStore>(() => "Collect.");
_logger.Debug<ContentStore>("Collect.");
#endif
while (_genRefRefs.TryPeek(out GenRefRef genRefRef) && (genRefRef.Count == 0 || genRefRef.WGenRef.IsAlive == false))
{
@@ -1098,7 +1098,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
#if DEBUG
_logger = logger;
_logger.Debug<Snapshot>(() => "Creating snapshot.");
_logger.Debug<Snapshot>("Creating snapshot.");
#endif
}
@@ -1113,7 +1113,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
#if DEBUG
_logger = logger;
_logger.Debug<Snapshot>(() => "Creating live.");
_logger.Debug<Snapshot>("Creating live.");
#endif
}
@@ -1194,7 +1194,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
{
if (_gen < 0) return;
#if DEBUG
_logger.Debug<Snapshot>(() => "Dispose snapshot (" + (_genRef?.GenRefRef.Count.ToString() ?? "live") + ").");
//WB: TODO Need to inspect what Snapshot prop is returning here
_logger.Debug<Snapshot>("Dispose snapshot ({Snapshot})", _genRef?.GenRefRef.Count.ToString() ?? "live");
#endif
_gen = -1;
if (_genRef != null)

View File

@@ -186,7 +186,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
{
if (Debugger.IsAttached)
throw new Exception("Missing cmsContentNu edited content for node " + dto.Id + ", consider rebuilding.");
Current.Logger.Warn<DatabaseDataSource>(() => $"Missing cmsContentNu edited content for node {dto.Id}, consider rebuilding.");
Current.Logger.Warn<DatabaseDataSource>("Missing cmsContentNu edited content for node {NodeId}, consider rebuilding.", dto.Id);
}
else
{
@@ -211,7 +211,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
{
if (Debugger.IsAttached)
throw new Exception("Missing cmsContentNu published content for node " + dto.Id + ", consider rebuilding.");
Current.Logger.Warn<DatabaseDataSource>(() => $"Missing cmsContentNu published content for node {dto.Id}, consider rebuilding.");
Current.Logger.Warn<DatabaseDataSource>("Missing cmsContentNu published content for node {NodeId}, consider rebuilding.", dto.Id);
}
else
{

View File

@@ -298,12 +298,12 @@ namespace Umbraco.Web.PublishedCache.NuCache
_localContentDb?.Clear();
_logger.Debug<PublishedSnapshotService>(() => "Loading content from database...");
_logger.Debug<PublishedSnapshotService>("Loading content from database...");
var sw = Stopwatch.StartNew();
var kits = _dataSource.GetAllContentSources(scope);
_contentStore.SetAll(kits);
sw.Stop();
_logger.Debug<PublishedSnapshotService>(() => "Loaded content from database (" + sw.ElapsedMilliseconds + "ms).");
_logger.Debug<PublishedSnapshotService>("Loaded content from database ({ElapsedMilliseconds}ms)", sw.ElapsedMilliseconds);
}
private void LoadContentFromLocalDbLocked(IScope scope)
@@ -312,12 +312,12 @@ namespace Umbraco.Web.PublishedCache.NuCache
.Select(x => _publishedContentTypeFactory.CreateContentType(x));
_contentStore.UpdateContentTypes(null, contentTypes, null);
_logger.Debug<PublishedSnapshotService>(() => "Loading content from local db...");
_logger.Debug<PublishedSnapshotService>("Loading content from local db...");
var sw = Stopwatch.StartNew();
var kits = _localContentDb.Select(x => x.Value).OrderBy(x => x.Node.Level);
_contentStore.SetAll(kits);
sw.Stop();
_logger.Debug<PublishedSnapshotService>(() => "Loaded content from local db (" + sw.ElapsedMilliseconds + "ms).");
_logger.Debug<PublishedSnapshotService>("Loaded content from local db ({ElapsedMilliseconds}ms)", sw.ElapsedMilliseconds);
}
// keep these around - might be useful
@@ -365,12 +365,12 @@ namespace Umbraco.Web.PublishedCache.NuCache
_localMediaDb?.Clear();
_logger.Debug<PublishedSnapshotService>(() => "Loading media from database...");
_logger.Debug<PublishedSnapshotService>("Loading media from database...");
var sw = Stopwatch.StartNew();
var kits = _dataSource.GetAllMediaSources(scope);
_mediaStore.SetAll(kits);
sw.Stop();
_logger.Debug<PublishedSnapshotService>(() => "Loaded media from database (" + sw.ElapsedMilliseconds + "ms).");
_logger.Debug<PublishedSnapshotService>("Loaded media from database ({ElapsedMilliseconds}ms)", sw.ElapsedMilliseconds);
}
private void LoadMediaFromLocalDbLocked(IScope scope)
@@ -379,12 +379,12 @@ namespace Umbraco.Web.PublishedCache.NuCache
.Select(x => _publishedContentTypeFactory.CreateContentType(x));
_mediaStore.UpdateContentTypes(null, mediaTypes, null);
_logger.Debug<PublishedSnapshotService>(() => "Loading media from local db...");
_logger.Debug<PublishedSnapshotService>("Loading media from local db...");
var sw = Stopwatch.StartNew();
var kits = _localMediaDb.Select(x => x.Value);
_mediaStore.SetAll(kits);
sw.Stop();
_logger.Debug<PublishedSnapshotService>(() => "Loaded media from local db (" + sw.ElapsedMilliseconds + "ms).");
_logger.Debug<PublishedSnapshotService>("Loaded media from local db ({ElapsedMilliseconds}ms)", sw.ElapsedMilliseconds);
}
// keep these around - might be useful
@@ -551,7 +551,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
foreach (var payload in payloads)
{
_logger.Debug<PublishedSnapshotService>(() => $"Notified {payload.ChangeTypes} for content {payload.Id}");
//WB: TODO Check ChangeTypes as its an enum (be nice to get the text & not 0, 1, 2)
_logger.Debug<PublishedSnapshotService>("Notified {ChangeTypes} for content {ContentId}", payload.ChangeTypes, payload.Id);
if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll))
{
@@ -641,7 +642,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
foreach (var payload in payloads)
{
_logger.Debug<PublishedSnapshotService>(() => $"Notified {payload.ChangeTypes} for media {payload.Id}");
//WB: TODO Check ChangeTypes as its an enum (be nice to get the text & not 0, 1, 2)
_logger.Debug<PublishedSnapshotService>("Notified {ChangeTypes} for media {MediaId}", payload.ChangeTypes, payload.Id);
if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll))
{
@@ -710,7 +712,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
return;
foreach (var payload in payloads)
_logger.Debug<PublishedSnapshotService>(() => $"Notified {payload.ChangeTypes} for {payload.ItemType} {payload.Id}");
//WB: TODO Check ChangeTypes as its an enum (be nice to get the text & not 0, 1, 2)
_logger.Debug<PublishedSnapshotService>("Notified {ChangeTypes} for {ItemType} {ItemId}", payload.ChangeTypes, payload.ItemType, payload.Id);
Notify<IContentType>(_contentStore, payloads, RefreshContentTypesLocked);
Notify<IMediaType>(_mediaStore, payloads, RefreshMediaTypesLocked);
@@ -760,7 +763,9 @@ namespace Umbraco.Web.PublishedCache.NuCache
var idsA = payloads.Select(x => x.Id).ToArray();
foreach (var payload in payloads)
_logger.Debug<PublishedSnapshotService>(() => $"Notified {(payload.Removed ? "Removed" : "Refreshed")} for data type {payload.Id}");
_logger.Debug<PublishedSnapshotService>("Notified {RemovedStatus} for data type {DataTypeId}",
payload.Removed ? "Removed" : "Refreshed",
payload.Id);
using (_contentStore.GetWriter(_scopeProvider))
using (_mediaStore.GetWriter(_scopeProvider))

View File

@@ -48,7 +48,7 @@ namespace Umbraco.Web.PublishedCache
/// </summary>
public void ClearAll()
{
_logger.Debug<PublishedContentTypeCache>(() => "Clear all.");
_logger.Debug<PublishedContentTypeCache>("Clear all.");
try
{
@@ -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 {id}.");
_logger.Debug<PublishedContentTypeCache>("Clear content type w/id {ContentTypeId}", 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 {id}.");
_logger.Debug<PublishedContentTypeCache>("Clear data type w/id {DataTypeId}.", 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

@@ -108,7 +108,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
else
{
// this is a property that does not correspond to anything, ignore and log
Current.Logger.Warn<PublishedMediaCache>(() => "Dropping property \"" + i.Key + "\" because it does not belong to the content type.");
Current.Logger.Warn<PublishedMediaCache>("Dropping property '{PropertyKey}' because it does not belong to the content type.", i.Key);
}
}
}

View File

@@ -330,8 +330,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 ({ExamineIndexMissMax} times) to retrieve medias from Examine index and had to load"
+ " them from DB. This may indicate that the Examine index is corrupted.");
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.", ExamineIndexMissMax);
return ConvertFromIMedia(media);
}
@@ -348,8 +348,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
: ConvertFromXPathNavigator(media.Current);
}
Current.Logger.Warn<PublishedMediaCache>(() =>
$"Could not retrieve media {id} from Examine index or from legacy library.GetMedia method");
Current.Logger.Warn<PublishedMediaCache>("Could not retrieve media {MediaId} from Examine index or from legacy library.GetMedia method", id);
return null;
}

View File

@@ -1038,7 +1038,8 @@ ORDER BY umbracoNode.level, umbracoNode.sortOrder";
{
foreach (var payload in payloads)
{
Current.Logger.Debug<XmlStore>(() => $"Notified {payload.ChangeTypes} for content {payload.Id}.");
//WB: TODO Check ChangeTypes as its an enum (be nice to get the text & not 0, 1, 2)
Current.Logger.Debug<XmlStore>("Notified {ChangeTypes} for content {ContentId}", payload.ChangeTypes, payload.Id);
if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll))
{
@@ -1071,7 +1072,8 @@ ORDER BY umbracoNode.level, umbracoNode.sortOrder";
if (content == null || content.Published == false || content.Trashed)
{
// no published version
Current.Logger.Debug<XmlStore>(() => $"Notified, content {payload.Id} has no published version.");
Current.Logger.Debug<XmlStore>("Notified, content {ContentId} has no published version.", payload.Id);
if (current != null)
{
// remove from xml if exists
@@ -1109,7 +1111,8 @@ ORDER BY umbracoNode.level, umbracoNode.sortOrder";
if (dtos.MoveNext() == false)
{
// gone fishing, remove (possible race condition)
Current.Logger.Debug<XmlStore>(() => $"Notifified, content {payload.Id} gone fishing.");
Current.Logger.Debug<XmlStore>("Notified, content {ContentId} gone fishing.", payload.Id);
if (current != null)
{
// remove from xml if exists
@@ -1222,7 +1225,8 @@ ORDER BY umbracoNode.level, umbracoNode.sortOrder";
.ToArray();
foreach (var payload in payloads)
Current.Logger.Debug<XmlStore>(() => $"Notified {payload.ChangeTypes} for content type {payload.Id}.");
//WB: TODO Check ChangeTypes as its an enum (be nice to get the text & not 0, 1, 2)
Current.Logger.Debug<XmlStore>("Notified {ChangeTypes} for content type {ContentTypeId}", payload.ChangeTypes, payload.Id);
if (ids.Length > 0) // must have refreshes, not only removes
RefreshContentTypes(ids);
@@ -1239,9 +1243,11 @@ ORDER BY umbracoNode.level, umbracoNode.sortOrder";
// the types will be reloaded if/when needed
foreach (var payload in payloads)
_contentTypeCache.ClearDataType(payload.Id);
foreach (var payload in payloads)
Current.Logger.Debug<XmlStore>(() => $"Notified {(payload.Removed ? "Removed" : "Refreshed")} for data type {payload.Id}.");
Current.Logger.Debug<XmlStore>("Notified {RemovedStatus} for data type {payload.Id}",
payload.Removed ? "Removed" : "Refreshed",
payload.Id);
// that's all we need to do as the changes have NO impact whatsoever on the Xml content

View File

@@ -62,7 +62,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
if (touched == false) return;
_logger.Debug<XmlStoreFilePersister>(() => $"Created, save in {WaitMilliseconds}ms.");
_logger.Debug<XmlStoreFilePersister>("Created, save in {WaitMilliseconds}ms.", WaitMilliseconds);
_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 {WaitMilliseconds}ms.");
_logger.Debug<XmlStoreFilePersister>("Touched, was idle, start and save in {WaitMilliseconds}ms.", WaitMilliseconds);
_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 {WaitMilliseconds}ms.");
_logger.Debug<XmlStoreFilePersister>("Touched, was waiting, can delay, save in {WaitMilliseconds}ms.", WaitMilliseconds);
_timer.Change(WaitMilliseconds, 0);
}
else

View File

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

View File

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

View File

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

View File

@@ -46,13 +46,13 @@ namespace Umbraco.Web.Routing
{
if (docreq == null) throw new System.ArgumentNullException(nameof(docreq));
Logger.Debug<ContentFinderByUrl>(() => $"Test route \"{route}\"");
Logger.Debug<ContentFinderByUrl>("Test route '{Route}'", route);
var node = docreq.UmbracoContext.ContentCache.GetByRoute(route, culture: docreq.Culture?.Name);
if (node != null)
{
docreq.PublishedContent = node;
Logger.Debug<ContentFinderByUrl>(() => $"Got content, id={node.Id}");
Logger.Debug<ContentFinderByUrl>("Got content, id={NodeId}", node.Id);
}
else
{

View File

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

View File

@@ -49,7 +49,7 @@ namespace Umbraco.Web.Routing
var template = _fileService.GetTemplate(templateAlias);
if (template != null)
{
Logger.Debug<ContentFinderByUrlAndTemplate>(() => $"Valid template: \"{templateAlias}\"");
Logger.Debug<ContentFinderByUrlAndTemplate>("Valid template: '{TemplateAlias}'", templateAlias);
var route = frequest.HasDomain ? (frequest.Domain.ContentId.ToString() + path) : path;
node = FindContent(frequest, route);
@@ -59,12 +59,12 @@ namespace Umbraco.Web.Routing
}
else
{
Logger.Debug<ContentFinderByUrlAndTemplate>(() => $"Not a valid template: \"{templateAlias}\"");
Logger.Debug<ContentFinderByUrlAndTemplate>("Not a valid template: '{TemplateAlias}'", templateAlias);
}
}
else
{
Logger.Debug<ContentFinderByUrlAndTemplate>("No template in path \"/\"");
Logger.Debug<ContentFinderByUrlAndTemplate>("No template in path '/'");
}
return node != null;

View File

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

View File

@@ -276,7 +276,7 @@ namespace Umbraco.Web.Routing
// note - we are not handling schemes nor ports here.
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Uri=\"{request.Uri}\"");
_logger.Debug<PublishedRouter>("{TracePrefix}Uri='{RequestUri}'", tracePrefix, request.Uri);
var domainsCache = request.UmbracoContext.PublishedSnapshot.Domains;
var domains = domainsCache.GetAll(includeWildcards: false).ToList();
@@ -313,7 +313,7 @@ namespace Umbraco.Web.Routing
if (domainAndUri != null)
{
// matching an existing domain
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Matches domain=\"{domainAndUri.Name}\", rootId={domainAndUri.ContentId}, culture=\"{domainAndUri.Culture}\"");
_logger.Debug<PublishedRouter>("{TracePrefix}Matches domain='{Domain}', rootId={RootContentId}, culture='{Culture}'", tracePrefix, domainAndUri.Name, domainAndUri.ContentId, domainAndUri.Culture);
request.Domain = domainAndUri;
request.Culture = domainAndUri.Culture;
@@ -328,12 +328,12 @@ namespace Umbraco.Web.Routing
else
{
// not matching any existing domain
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Matches no domain");
_logger.Debug<PublishedRouter>("{TracePrefix}Matches no domain", tracePrefix);
request.Culture = defaultCulture == null ? CultureInfo.CurrentUICulture : new CultureInfo(defaultCulture);
}
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Culture=\"{request.Culture.Name}\"");
_logger.Debug<PublishedRouter>("{TracePrefix}Culture='{CultureName}'", tracePrefix, request.Culture.Name);
return request.Domain != null;
}
@@ -349,7 +349,7 @@ namespace Umbraco.Web.Routing
return;
var nodePath = request.PublishedContent.Path;
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Path=\"{nodePath}\"");
_logger.Debug<PublishedRouter>("{TracePrefix}Path='{NodePath}'", tracePrefix, nodePath);
var rootNodeId = request.HasDomain ? request.Domain.ContentId : (int?)null;
var domain = DomainHelper.FindWildcardDomainInPath(request.UmbracoContext.PublishedSnapshot.Domains.GetAll(true), nodePath, rootNodeId);
@@ -357,11 +357,11 @@ namespace Umbraco.Web.Routing
if (domain != null)
{
request.Culture = domain.Culture;
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Got domain on node {domain.ContentId}, set culture to \"{request.Culture.Name}\".");
_logger.Debug<PublishedRouter>("{TracePrefix}Got domain on node {DomainContentId}, set culture to '{CultureName}'", tracePrefix, domain.ContentId, request.Culture.Name);
}
else
{
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}No match.");
_logger.Debug<PublishedRouter>("{TracePrefix}No match.", tracePrefix);
}
}
@@ -434,8 +434,7 @@ namespace Umbraco.Web.Routing
/// <returns>A value indicating whether a document and template were found.</returns>
private void FindPublishedContentAndTemplate(PublishedRequest request)
{
const string tracePrefix = "FindPublishedContentAndTemplate: ";
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Path=\"{request.Uri.AbsolutePath}\"");
_logger.Debug<PublishedRouter>("FindPublishedContentAndTemplate: Path='{UriAbsolutePath}'", request.Uri.AbsolutePath);
// run the document finders
FindPublishedContent(request);
@@ -478,7 +477,7 @@ namespace Umbraco.Web.Routing
//iterate but return on first one that finds it
var found = _contentFinders.Any(finder =>
{
_logger.Debug<PublishedRouter>(() => "Finder " + finder.GetType().FullName);
_logger.Debug<PublishedRouter>("Finder {ContentFinderType}", finder.GetType().FullName);
return finder.TryFindContent(request);
});
}
@@ -504,22 +503,22 @@ namespace Umbraco.Web.Routing
const int maxLoop = 8;
do
{
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}{(i == 0 ? "Begin" : "Loop")}");
_logger.Debug<PublishedRouter>("HandlePublishedContent: Loop {LoopCounter}", i);
// handle not found
if (request.HasPublishedContent == false)
{
request.Is404 = true;
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}No document, try last chance lookup");
_logger.Debug<PublishedRouter>("HandlePublishedContent: 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>(() => $"{tracePrefix}Failed to find a document, give up");
_logger.Debug<PublishedRouter>("HandlePublishedContent: Failed to find a document, give up");
break;
}
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Found a document");
_logger.Debug<PublishedRouter>("HandlePublishedContent: Found a document");
}
// follow internal redirects as long as it's not running out of control ie infinite loop of some sort
@@ -541,11 +540,11 @@ namespace Umbraco.Web.Routing
if (i == maxLoop || j == maxLoop)
{
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Looks like we're running into an infinite loop, abort");
_logger.Debug<PublishedRouter>("HandlePublishedContent: Looks like we're running into an infinite loop, abort");
request.PublishedContent = null;
}
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}End");
_logger.Debug<PublishedRouter>("HandlePublishedContent: End");
}
/// <summary>
@@ -558,8 +557,6 @@ namespace Umbraco.Web.Routing
/// </remarks>
private bool FollowInternalRedirects(PublishedRequest request)
{
const string tracePrefix = "FollowInternalRedirects: ";
if (request.PublishedContent == null)
throw new InvalidOperationException("There is no PublishedContent.");
@@ -592,23 +589,25 @@ namespace Umbraco.Web.Routing
if (valid == false)
{
// bad redirect - log and display the current page (legacy behavior)
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Failed to redirect to id={request.PublishedContent.GetProperty(Constants.Conventions.Content.InternalRedirectId).GetSourceValue()}: value is not an int nor a GuidUdi.");
_logger.Debug<PublishedRouter>("FollowInternalRedirects: Failed to redirect to id={InternalRedirectId}: value is not an int nor a GuidUdi.",
request.PublishedContent.GetProperty(Constants.Conventions.Content.InternalRedirectId).GetSourceValue());
}
if (internalRedirectNode == null)
{
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Failed to redirect to id={request.PublishedContent.GetProperty(Constants.Conventions.Content.InternalRedirectId).GetSourceValue()}: no such published document.");
_logger.Debug<PublishedRouter>("FollowInternalRedirects: Failed to redirect to id={InternalRedirectId}: no such published document.",
request.PublishedContent.GetProperty(Constants.Conventions.Content.InternalRedirectId).GetSourceValue());
}
else if (internalRedirectId == request.PublishedContent.Id)
{
// redirect to self
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Redirecting to self, ignore");
_logger.Debug<PublishedRouter>("FollowInternalRedirects: Redirecting to self, ignore");
}
else
{
request.SetInternalRedirectPublishedContent(internalRedirectNode); // don't use .PublishedContent here
redirect = true;
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Redirecting to id={internalRedirectId}");
_logger.Debug<PublishedRouter>("FollowInternalRedirects: Redirecting to id={InternalRedirectId}", internalRedirectId);
}
return redirect;
@@ -620,8 +619,6 @@ namespace Umbraco.Web.Routing
/// <remarks>Redirecting to a different site root and/or culture will not pick the new site root nor the new culture.</remarks>
private void EnsurePublishedContentAccess(PublishedRequest request)
{
const string tracePrefix = "EnsurePublishedContentAccess: ";
if (request.PublishedContent == null)
throw new InvalidOperationException("There is no PublishedContent.");
@@ -631,13 +628,13 @@ namespace Umbraco.Web.Routing
if (publicAccessAttempt)
{
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Page is protected, check for access");
_logger.Debug<PublishedRouter>("EnsurePublishedContentAccess: Page is protected, check for access");
var membershipHelper = new MembershipHelper(request.UmbracoContext);
if (membershipHelper.IsLoggedIn() == false)
{
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Not logged in, redirect to login page");
_logger.Debug<PublishedRouter>("EnsurePublishedContentAccess: Not logged in, redirect to login page");
var loginPageId = publicAccessAttempt.Result.LoginNodeId;
@@ -646,19 +643,19 @@ namespace Umbraco.Web.Routing
}
else if (_services.PublicAccessService.HasAccess(request.PublishedContent.Id, _services.ContentService, GetRolesForLogin(membershipHelper.CurrentUserName)) == false)
{
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Current member has not access, redirect to error page");
_logger.Debug<PublishedRouter>("EnsurePublishedContentAccess: Current member has not access, redirect to error page");
var errorPageId = publicAccessAttempt.Result.NoAccessNodeId;
if (errorPageId != request.PublishedContent.Id)
request.PublishedContent = request.UmbracoContext.PublishedSnapshot.Content.GetById(errorPageId);
}
else
{
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Current member has access");
_logger.Debug<PublishedRouter>("EnsurePublishedContentAccess: Current member has access");
}
}
else
{
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Page is not protected");
_logger.Debug<PublishedRouter>("EnsurePublishedContentAccess: Page is not protected");
}
}
@@ -671,8 +668,6 @@ namespace Umbraco.Web.Routing
// use the Prepared event to change the template if they wish. Should we also
// implement an ITemplateFinder logic?
const string tracePrefix = "FindTemplate: ";
if (request.PublishedContent == null)
{
request.TemplateModel = null;
@@ -709,16 +704,16 @@ namespace Umbraco.Web.Routing
if (templateId > 0)
{
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Look for template id={templateId}");
_logger.Debug<PublishedRouter>("FindTemplate: Look for template id={TemplateId}", 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>(() => $"{tracePrefix}Got template id={template.Id} alias=\"{template.Alias}\"");
_logger.Debug<PublishedRouter>("FindTemplate: Got template id={TemplateId} alias='{TemplateAlias}'", template.Id, template.Alias);
}
else
{
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}No specified template.");
_logger.Debug<PublishedRouter>("FindTemplate: No specified template.");
}
}
else
@@ -730,24 +725,24 @@ namespace Umbraco.Web.Routing
// ignore if the alias does not match - just trace
if (request.HasTemplate)
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Has a template already, but also an alternate template.");
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Look for alternate template alias=\"{altTemplate}\"");
_logger.Debug<PublishedRouter>("FindTemplate: Has a template already, but also an alternate template.");
_logger.Debug<PublishedRouter>("FindTemplate: Look for alternate template alias='{AltTemplate}'", altTemplate);
var template = _services.FileService.GetTemplate(altTemplate);
if (template != null)
{
request.TemplateModel = template;
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Got template id={template.Id} alias=\"{template.Alias}\"");
_logger.Debug<PublishedRouter>("FindTemplate: Got template id={TemplateId} alias='{TemplateAlias}'", template.Id, template.Alias);
}
else
{
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}The template with alias=\"{altTemplate}\" does not exist, ignoring.");
_logger.Debug<PublishedRouter>("FindTemplate: The template with alias='{AltTemplate}' does not exist, ignoring.", altTemplate);
}
}
if (request.HasTemplate == false)
{
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}No template was found.");
_logger.Debug<PublishedRouter>("FindTemplate: 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.
@@ -760,7 +755,7 @@ namespace Umbraco.Web.Routing
}
else
{
_logger.Debug<PublishedRouter>(() => $"{tracePrefix}Running with template id={request.TemplateModel.Id} alias=\"{request.TemplateModel.Alias}\"");
_logger.Debug<PublishedRouter>("FindTemplate: Running with template id={TemplateId} alias='{TemplateAlias}'", request.TemplateModel.Id, 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 " + task.GetType().FullName);
_logger.Debug<BackgroundTaskRunner>("{LogPrefix} Task Added {TaskType}", _logPrefix , 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 {task.GetType().FullName}, the task runner has already shutdown");
_logger.Debug<BackgroundTaskRunner>("{LogPrefix} Task cannot be added {TaskType}, the task runner has already shutdown", _logPrefix, task.GetType().FullName);
return false;
}
// add task
_logger.Debug<BackgroundTaskRunner>(() => _logPrefix + "Task added " + task.GetType().FullName);
_logger.Debug<BackgroundTaskRunner>("{LogPrefix} Task added {TaskType}", _logPrefix, task.GetType().FullName);
_tasks.Post(task);
// start
@@ -315,7 +315,7 @@ namespace Umbraco.Web.Scheduling
_shutdownToken = _shutdownTokenSource.Token;
_runningTask = Task.Run(async () => await Pump().ConfigureAwait(false), _shutdownToken);
_logger.Debug<BackgroundTaskRunner>(() => _logPrefix + "Starting");
_logger.Debug<BackgroundTaskRunner>("{LogPrefix} Starting", _logPrefix);
}
/// <summary>
@@ -389,7 +389,7 @@ namespace Umbraco.Web.Scheduling
}
catch (Exception e)
{
_logger.Error<BackgroundTaskRunner>(_logPrefix + "Task runner exception.", e);
_logger.Error<BackgroundTaskRunner>("{LogPrefix} Task runner exception", e, _logPrefix);
}
// done
@@ -414,7 +414,7 @@ namespace Umbraco.Web.Scheduling
if (_shutdownToken.IsCancellationRequested == false && _tasks.Count > 0) continue;
// if we really have nothing to do, stop
_logger.Debug<BackgroundTaskRunner>(() => _logPrefix + "Stopping");
_logger.Debug<BackgroundTaskRunner>("{LogPrefix} Stopping", _logPrefix);
if (_options.PreserveRunningTask == false)
_runningTask = null;
@@ -536,7 +536,8 @@ namespace Umbraco.Web.Scheduling
}
catch (Exception ex)
{
_logger.Error<BackgroundTaskRunner>(_logPrefix + "Task has failed", ex);
_logger.Error<BackgroundTaskRunner>("{LogPrefix} Task has failed", ex, _logPrefix);
}
}
@@ -667,7 +668,7 @@ namespace Umbraco.Web.Scheduling
if (_terminating == false)
{
_terminating = true;
_logger.Info<BackgroundTaskRunner>(() => $"{_logPrefix}Terminating{(immediate ? immediate.ToString() : "")}");
_logger.Info<BackgroundTaskRunner>("{LogPrefix} Terminating {Immediate}", _logPrefix, immediate ? immediate.ToString() : string.Empty);
onTerminating = true;
}
}
@@ -681,7 +682,7 @@ namespace Umbraco.Web.Scheduling
// processing, call the UnregisterObject method, and then return or it can return immediately and complete
// processing asynchronously before calling the UnregisterObject method.
_logger.Info<BackgroundTaskRunner>(() => _logPrefix + "Waiting for tasks to complete");
_logger.Info<BackgroundTaskRunner>("{LogPrefix} Waiting for tasks to complete", _logPrefix);
Shutdown(false, false); // do not accept any more tasks, flush the queue, do not wait
// raise the completed event only after the running threading task has completed
@@ -700,7 +701,7 @@ namespace Umbraco.Web.Scheduling
// immediate parameter is true, the registered object must call the UnregisterObject method before returning;
// otherwise, its registration will be removed by the application manager.
_logger.Info<BackgroundTaskRunner>(() => _logPrefix + "Cancelling tasks");
_logger.Info<BackgroundTaskRunner>("{LogPrefix} Cancelling tasks", _logPrefix);
Shutdown(true, true); // cancel all tasks, wait for the current one to end
Terminate(true);
}
@@ -723,7 +724,9 @@ namespace Umbraco.Web.Scheduling
terminatedSource = _terminatedSource;
}
_logger.Info<BackgroundTaskRunner>(() => _logPrefix + "Tasks " + (immediate ? "cancelled" : "completed") + ", terminated");
_logger.Info<BackgroundTaskRunner>("{LogPrefix} Tasks {TaskStatus}, terminated",
_logPrefix,
immediate ? "cancelled" : "completed");
OnEvent(Terminated, "Terminated");

View File

@@ -87,7 +87,7 @@ namespace Umbraco.Web.Scheduling
{
LazyInitializer.EnsureInitialized(ref _tasks, ref _started, ref _locker, () =>
{
_logger.Debug<SchedulerComponent>(() => "Initializing the scheduler");
_logger.Debug<SchedulerComponent>("Initializing the scheduler");
var settings = UmbracoConfig.For.UmbracoSettings();
var tasks = new List<IBackgroundTask>();

View File

@@ -91,7 +91,7 @@ namespace Umbraco.Web.Search
var registeredIndexers = examineManager.IndexProviders.Values.OfType<UmbracoExamineIndexer>().Count(x => x.EnableDefaultEventHandler);
profilingLogger.Logger.Info<ExamineComponent>(() => $"Adding examine event handlers for {registeredIndexers} index providers.");
profilingLogger.Logger.Info<ExamineComponent>("Adding examine event handlers for {RegisteredIndexers} index providers.", registeredIndexers);
// don't bind event handlers if we're not suppose to listen
if (registeredIndexers == 0)
@@ -200,7 +200,7 @@ namespace Umbraco.Web.Search
var dir = luceneIndexer.GetLuceneDirectory();
if (IndexWriter.IsLocked(dir))
{
logger.Info<ExamineComponent>(() => $"Forcing index {luceneIndexer.Name} to be unlocked since it was left in a locked state");
logger.Info<ExamineComponent>("Forcing index {IndexerName} to be unlocked since it was left in a locked state", luceneIndexer.Name);
IndexWriter.Unlock(dir);
}
}

View File

@@ -301,7 +301,7 @@ namespace Umbraco.Web.Security
if (member == null)
{
//this should not happen
Current.Logger.Warn<MembershipHelper>(() => $"The member validated but then no member was returned with the username {username}");
Current.Logger.Warn<MembershipHelper>("The member validated but then no member was returned with the username {Username}", username);
return false;
}
//Log them in

View File

@@ -149,7 +149,7 @@ namespace Umbraco.Web.Security.Providers
if (MemberService.Exists(username))
{
status = MembershipCreateStatus.DuplicateUserName;
Current.Logger.Warn<UmbracoMembershipProvider<T, TEntity>>(() => $"Cannot create member as username already exists: {username}");
Current.Logger.Warn<UmbracoMembershipProvider<T, TEntity>>("Cannot create member as username already exists: {Username}", username);
return null;
}
@@ -157,7 +157,7 @@ namespace Umbraco.Web.Security.Providers
if (MemberService.GetByEmail(email) != null && RequiresUniqueEmail)
{
status = MembershipCreateStatus.DuplicateEmail;
Current.Logger.Warn<UmbracoMembershipProvider<T, TEntity>>(() => $"Cannot create member as a member with the same email address exists: {email}");
Current.Logger.Warn<UmbracoMembershipProvider<T, TEntity>>("Cannot create member as a member with the same email address exists: {Email}", email);
return null;
}
@@ -524,8 +524,7 @@ namespace Umbraco.Web.Security.Providers
if (member == null)
{
Current.Logger.Info<UmbracoMembershipProviderBase>(() =>
$"Login attempt failed for username {username} from IP address {GetCurrentRequestIpAddress()}, the user does not exist" );
Current.Logger.Info<UmbracoMembershipProviderBase>("Login attempt failed for username {Username} from IP address {IpAddress}, the user does not exist", username, GetCurrentRequestIpAddress());
return new ValidateUserResult
{
@@ -535,8 +534,7 @@ namespace Umbraco.Web.Security.Providers
if (member.IsApproved == false)
{
Current.Logger.Info<UmbracoMembershipProviderBase>(() =>
$"Login attempt failed for username {username} from IP address {GetCurrentRequestIpAddress()}, the user is not approved");
Current.Logger.Info<UmbracoMembershipProviderBase>("Login attempt failed for username {Username} from IP address {IpAddress}, the user is not approved", username, GetCurrentRequestIpAddress());
return new ValidateUserResult
{
@@ -546,8 +544,7 @@ namespace Umbraco.Web.Security.Providers
}
if (member.IsLockedOut)
{
Current.Logger.Info<UmbracoMembershipProviderBase>(() =>
$"Login attempt failed for username {username} from IP address {GetCurrentRequestIpAddress()}, the user is locked");
Current.Logger.Info<UmbracoMembershipProviderBase>("Login attempt failed for username {Username} from IP address {IpAddress}, the user is locked", username, GetCurrentRequestIpAddress());
return new ValidateUserResult
{
@@ -571,13 +568,11 @@ namespace Umbraco.Web.Security.Providers
member.IsLockedOut = true;
member.LastLockoutDate = DateTime.Now;
Current.Logger.Info<UmbracoMembershipProviderBase>(() =>
$"Login attempt failed for username {username} from IP address {GetCurrentRequestIpAddress()}, the user is now locked out, max invalid password attempts exceeded");
Current.Logger.Info<UmbracoMembershipProviderBase>("Login attempt failed for username {Username} from IP address {IpAddress}, the user is now locked out, max invalid password attempts exceeded", username, GetCurrentRequestIpAddress());
}
else
{
Current.Logger.Info<UmbracoMembershipProviderBase>(() =>
$"Login attempt failed for username {username} from IP address {GetCurrentRequestIpAddress()}");
Current.Logger.Info<UmbracoMembershipProviderBase>("Login attempt failed for username {Username} from IP address {IpAddress}", username, GetCurrentRequestIpAddress());
}
}
else
@@ -590,8 +585,7 @@ namespace Umbraco.Web.Security.Providers
member.LastLoginDate = DateTime.Now;
Current.Logger.Info<UmbracoMembershipProviderBase>(() =>
$"Login attempt succeeded for username {username} from IP address {GetCurrentRequestIpAddress()}");
Current.Logger.Info<UmbracoMembershipProviderBase>("Login attempt succeeded for username {Username} from IP address {IpAddress}", username, GetCurrentRequestIpAddress());
}
//don't raise events for this! It just sets the member dates, if we do raise events this will

View File

@@ -339,7 +339,7 @@ namespace Umbraco.Web.Services
var clrType = Type.GetType(type);
if (clrType == null)
{
_logger.Warn<ApplicationTreeService>(() => $"The tree definition: {addElement} could not be resolved to a .Net object type");
_logger.Warn<ApplicationTreeService>("The tree definition: {AddElement} could not be resolved to a .Net object type", addElement);
continue;
}

View File

@@ -354,7 +354,10 @@ namespace Umbraco.Web
var end = false;
var response = context.Response;
logger.Debug<UmbracoModule>(() => $"Response status: Redirect={(pcr.IsRedirect ? (pcr.IsRedirectPermanent ? "permanent" : "redirect") : "none")}, Is404={(pcr.Is404 ? "true" : "false")}, StatusCode={pcr.ResponseStatusCode}");
logger.Debug<UmbracoModule>("Response status: Redirect={Redirect}, Is404={Is404}, StatusCode={ResponseStatusCode}",
pcr.IsRedirect ? (pcr.IsRedirectPermanent ? "permanent" : "redirect") : "none",
pcr.Is404 ? "true" : "false",
pcr.ResponseStatusCode);
if(pcr.Cacheability != default)
response.Cache.SetCacheability(pcr.Cacheability);
@@ -551,7 +554,7 @@ namespace Umbraco.Web
app.BeginRequest += (sender, e) =>
{
var httpContext = ((HttpApplication) sender).Context;
Logger.Debug<UmbracoModule>(() => $"Begin request: {httpContext.Request.Url}.");
Logger.Debug<UmbracoModule>("Begin request: {RequestUrl}", httpContext.Request.Url);
BeginRequest(new HttpContextWrapper(httpContext));
};
@@ -594,7 +597,7 @@ namespace Umbraco.Web
if (UmbracoContext.Current != null && UmbracoContext.Current.IsFrontEndUmbracoRequest)
{
Logger.Debug<UmbracoModule>(() => $"End Request. ({DateTime.Now.Subtract(UmbracoContext.Current.ObjectCreated).TotalMilliseconds}ms)");
Logger.Debug<UmbracoModule>("End Request: {RequestUrl} ({RequestTotalMilliseconds}ms)", httpContext.Request.Url, DateTime.Now.Subtract(UmbracoContext.Current.ObjectCreated).TotalMilliseconds);
}
OnEndRequest(new UmbracoRequestEventArgs(UmbracoContext.Current, new HttpContextWrapper(httpContext)));