Shorten metadata logging
This commit is contained in:
parent
27b8d5b3ee
commit
58eae51d40
@ -128,25 +128,49 @@ final class MetadataInfoLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func printMetadataScanOverview() {
|
func printMetadataScanOverview() {
|
||||||
|
var notes = [String]()
|
||||||
|
func addIfNotZero<S>(_ sequence: Array<S>, _ name: String) {
|
||||||
|
guard sequence.count > 0 else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
notes.append("\(sequence.count) \(name)")
|
||||||
|
}
|
||||||
|
addIfNotZero(warnings, "warnings")
|
||||||
|
addIfNotZero(errors, "errors")
|
||||||
|
addIfNotZero(unreadableMetadata, "unreadable files")
|
||||||
|
addIfNotZero(unusedProperties, "unused properties")
|
||||||
|
addIfNotZero(invalidProperties, "invalidProperties")
|
||||||
|
addIfNotZero(unknownProperties, "unknownProperties")
|
||||||
|
addIfNotZero(missingProperties, "missingProperties")
|
||||||
|
|
||||||
print(" Number of pages: \(numberOfMetadataFiles)")
|
print(" Number of pages: \(numberOfMetadataFiles)")
|
||||||
print(" Warnings: \(warnings.count)")
|
print(" Notes: " + notes.joined(separator: ", "))
|
||||||
print(" Errors: \(errors.count)")
|
|
||||||
print(" Unreadable files: \(unreadableMetadata.count)")
|
|
||||||
print(" Unused properties: \(unusedProperties.count)")
|
|
||||||
print(" Invalid properties: \(invalidProperties.count)")
|
|
||||||
print(" Unknown properties: \(unknownProperties.count)")
|
|
||||||
print(" Missing properties: \(missingProperties.count)")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeResultsToFile(in folder: URL) throws {
|
func writeResultsToFile(in folder: URL) throws {
|
||||||
let url = folder.appendingPathComponent("Metadata issues.txt")
|
let url = folder.appendingPathComponent("Metadata issues.txt")
|
||||||
var lines = ["Errors:"] + errors.map { "\($0.source): \($0.message)" }
|
var lines: [String] = []
|
||||||
|
if !errors.isEmpty {
|
||||||
|
lines += ["Errors:"] + errors.map { "\($0.source): \($0.message)" }
|
||||||
|
}
|
||||||
|
if !warnings.isEmpty {
|
||||||
lines += ["Warnings:"] + warnings.map { "\($0.source): \($0.message)" }
|
lines += ["Warnings:"] + warnings.map { "\($0.source): \($0.message)" }
|
||||||
|
}
|
||||||
|
if !unreadableMetadata.isEmpty {
|
||||||
lines += ["Unreadable files:"] + unreadableMetadata.map { "\($0.source): \($0.error)" }
|
lines += ["Unreadable files:"] + unreadableMetadata.map { "\($0.source): \($0.error)" }
|
||||||
|
}
|
||||||
|
if !unusedProperties.isEmpty {
|
||||||
lines += ["Unused properties:"] + unusedProperties.map { "\($0.source): \($0.name)" }
|
lines += ["Unused properties:"] + unusedProperties.map { "\($0.source): \($0.name)" }
|
||||||
|
}
|
||||||
|
if !invalidProperties.isEmpty {
|
||||||
lines += ["Invalid properties:"] + invalidProperties.map { "\($0.source): \($0.name) (\($0.reason))" }
|
lines += ["Invalid properties:"] + invalidProperties.map { "\($0.source): \($0.name) (\($0.reason))" }
|
||||||
|
}
|
||||||
|
if !unknownProperties.isEmpty {
|
||||||
lines += ["Unknown properties:"] + unknownProperties.map { "\($0.source): \($0.name)" }
|
lines += ["Unknown properties:"] + unknownProperties.map { "\($0.source): \($0.name)" }
|
||||||
|
}
|
||||||
|
if !missingProperties.isEmpty {
|
||||||
lines += ["Missing properties:"] + missingProperties.map { "\($0.source): \($0.name)" }
|
lines += ["Missing properties:"] + missingProperties.map { "\($0.source): \($0.name)" }
|
||||||
|
}
|
||||||
|
|
||||||
let data = lines.joined(separator: "\n").data(using: .utf8)
|
let data = lines.joined(separator: "\n").data(using: .utf8)
|
||||||
try data?.createFolderAndWrite(to: url)
|
try data?.createFolderAndWrite(to: url)
|
||||||
|
@ -23,6 +23,7 @@ private func loadSiteData(in folder: URL) throws -> Element? {
|
|||||||
let root = Element(atRoot: folder, log: log)
|
let root = Element(atRoot: folder, log: log)
|
||||||
print(" ")
|
print(" ")
|
||||||
log.printMetadataScanOverview()
|
log.printMetadataScanOverview()
|
||||||
|
print(" ")
|
||||||
try log.writeResultsToFile(in: files.generatorInfoFolder)
|
try log.writeResultsToFile(in: files.generatorInfoFolder)
|
||||||
return root
|
return root
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user