Skip to content

Commit c49f5a8

Browse files
committed
adding more log messages for debugging purposes.
changing some debug to warnings.
1 parent ec4807f commit c49f5a8

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/Umbraco.Deploy.Contrib.Connectors/ValueConnectors/BlockEditorValueConnector.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,36 @@ public BlockEditorValueConnector(IContentTypeService contentTypeService, Lazy<Va
3939

4040
public string ToArtifact(object value, PropertyType propertyType, ICollection<ArtifactDependency> dependencies)
4141
{
42+
_logger.Info<BlockEditorValueConnector>("Converting {PropertyType} to artifact.", propertyType.Alias);
4243
var svalue = value as string;
4344

4445
// nested values will arrive here as JObject - convert to string to enable reuse of same code as when non-nested.
4546
if (value is JObject)
47+
{
48+
_logger.Debug<BlockListValueConnector>("Value is a JObject - converting to string.");
4649
svalue = value.ToString();
50+
}
4751

4852
if (string.IsNullOrWhiteSpace(svalue))
53+
{
54+
_logger.Warn<BlockEditorValueConnector>($"Value is null or whitespace. Skipping creating artifact.");
4955
return null;
56+
}
5057

5158
if (svalue.DetectIsJson() == false)
59+
{
60+
_logger.Warn<BlockListValueConnector>("Value {Value} is not a json string. Skipping creating artifact.",
61+
svalue);
5262
return null;
63+
}
64+
5365
var blockEditorValue = JsonConvert.DeserializeObject<BlockEditorValue>(svalue);
5466

5567
if (blockEditorValue == null)
68+
{
69+
_logger.Warn<BlockEditorValueConnector>("Deserialized value is null. Skipping creating artifact.");
5670
return null;
71+
}
5772

5873
var allBlocks = blockEditorValue.Content.Concat(blockEditorValue.Settings);
5974

@@ -76,6 +91,7 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
7691
//Ensure that these content types have dependencies added
7792
foreach (var contentType in allContentTypes.Values)
7893
{
94+
_logger.Debug<BlockEditorValueConnector>("Adding dependency for content type {ContentType}.", contentType.Alias);
7995
dependencies.Add(new ArtifactDependency(contentType.GetUdi(), false, ArtifactDependencyMode.Match));
8096
}
8197

@@ -89,7 +105,7 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
89105

90106
if (propType == null)
91107
{
92-
_logger.Debug<BlockEditorValueConnector>("No property type found with alias {Key} on content type {ContentTypeAlias}.", key, contentType.Alias);
108+
_logger.Warn<BlockEditorValueConnector>("No property type found with alias {Key} on content type {ContentTypeAlias}.", key, contentType.Alias);
93109
continue;
94110
}
95111

@@ -101,7 +117,7 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
101117
var val = block.PropertyValues[key];
102118
object parsedValue = propValueConnector.ToArtifact(val, propType, dependencies);
103119

104-
_logger.Debug<BlockEditorValueConnector>("Map {Key} value '{PropertyValue}' to '{ParsedValue}' using {PropValueConnectorType} for {PropTypeAlias}.", key, block.PropertyValues[key], parsedValue, propValueConnector.GetType(), propType.Alias);
120+
_logger.Debug<BlockEditorValueConnector>("Mapped {Key} value '{PropertyValue}' to '{ParsedValue}' using {PropValueConnectorType} for {PropTypeAlias}.", key, block.PropertyValues[key], parsedValue, propValueConnector.GetType(), propType.Alias);
105121

106122
parsedValue = parsedValue?.ToString();
107123

@@ -110,7 +126,8 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar
110126
}
111127

112128
value = JsonConvert.SerializeObject(blockEditorValue);
113-
return (string)value;
129+
_logger.Info<BlockEditorValueConnector>("Finished converting {PropertyType} to artifact.", propertyType.Alias);
130+
return (string) value;
114131
}
115132

116133
public object FromArtifact(string value, PropertyType propertyType, object currentValue)
@@ -155,7 +172,7 @@ public object FromArtifact(string value, PropertyType propertyType, object curre
155172

156173
if (innerPropertyType == null)
157174
{
158-
_logger.Debug<BlockEditorValueConnector>("No property type found with alias {Key} on content type {ContentTypeAlias}.", key, contentType.Alias);
175+
_logger.Warn<BlockEditorValueConnector>("No property type found with alias {Key} on content type {ContentTypeAlias}.", key, contentType.Alias);
159176
continue;
160177
}
161178

0 commit comments

Comments
 (0)