Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This is an example of a report created from the Build Log of the [Kickstarter iO
`XCLogParser` is written as a [SPM](https://github.com/apple/swift-package-manager/) executable and it supports three commands:

1. [Dump](#dump-command) the contents of an `xcactivitylog` into a `JSON` document.
2. [Parse](#parse-command) the contents of an `xcactivitylog` into different kind of reports (`json`, `flatJson`, `chromeTracer` and `html`).
2. [Parse](#parse-command) the contents of an `xcactivitylog` into different kind of reports (`json`, `flatJson`, `summaryJson`, `chromeTracer` and `html`).
3. Dump the [Manifest](#manifest-command) contents of a `LogStoreManifest.plist` file into a `JSON` document.

Depending on your needs, there are various use-cases where `XCLogParser` can help you:
Expand Down Expand Up @@ -93,7 +93,7 @@ An example output has been omitted for brevity since it can contain a lot of inf

### Parse Command

Parses the build information from a `xcactivitylog` and converts it into different representations such as a [JSON file](#JSON-Reporter), [flat JSON file](#FlatJson-Reporter), [Chrome Tracer file](#ChromeTracer-Reporter) or a static [HTML page](#HTML-Reporter).
Parses the build information from a `xcactivitylog` and converts it into different representations such as a [JSON file](#JSON-Reporter), [flat JSON file](#FlatJson-Reporter), [summary JSON file](#SummaryJson-Reporter), [Chrome Tracer file](#ChromeTracer-Reporter) or a static [HTML page](#HTML-Reporter).

Examples:

Expand All @@ -110,7 +110,7 @@ Example output available in the [reporters](#reporters) section.

| Parameter Name | Description | Required |
|-----|---|-----|
| `--reporter` | The reporter used to transform the logs. It can be either `json`, `flatJson`, `chromeTracer` or `html`. (required) | Yes |
| `--reporter` | The reporter used to transform the logs. It can be either `json`, `flatJson`, `summaryJson`, `chromeTracer` or `html`. (required) | Yes |
| `--file` | The path to the `xcactivitylog`. | No * |
| `--project` | The name of the project if you don't know the path to the log. The tool will try to find the latest Build log in a folder that starts with that name inside the `DerivedData` directory. | No * |
| `--workspace` | The path to the `xcworkspace` file if you don't know the path to the log. It will generate the folder name for the project in the `DerivedData` folder using Xcode's hash algorithm and it will try to locate the latest Build Log inside that directory. | No * |
Expand Down Expand Up @@ -169,6 +169,7 @@ The [parse command](#parse-command) has different types of reporters built-in th

- [JSON](#json-reporter)
- [Flat JSON](#flatojson-reporter)
- [Summary JSON](#summaryjson-reporter)
- [Chrome Tracer](#chrometracer-reporter)
- [HTML](#html-reporter)

Expand Down Expand Up @@ -317,6 +318,50 @@ xclogparser parse --file path/to/log.xcactivitylog --reporter flatJson
```
</details>

For more information regarding each field, check out the [JSON format documentation](https://github.com/spotify/XCLogParser/blob/master/docs/JSON%20Format.md).

### SummaryJson Reporter

Parses the log as a JSON object, with no nested steps (the field `subSteps` is always empty). Useful to get a high level summary of the build.

Example:

```bash
xclogparser parse --file path/to/log.xcactivitylog --reporter summaryJson
```

<details>
<summary>Example Output</summary>

```json
{
"parentIdentifier" : "",
"title" : "Build MobiusCore",
"warningCount" : 0,
"duration" : 0,
"startTimestamp" : 1558590748,
"signature" : "Build MobiusCore",
"endDate" : "2019-05-23T05:52:28.274000Z",
"errorCount" : 0,
"domain" : "Xcode.IDEActivityLogDomainType.BuildLog",
"type" : "main",
"identifier" : "68a2bbd0048a454d91b3734b5d5dc45e_1558640253_1",
"buildStatus" : "succeeded",
"schema" : "MobiusCore",
"subSteps" : [

],
"endTimestamp" : 1558590748,
"architecture" : "",
"machineName" : "68a2bbd0048a454d91b3734b5d5dc45e",
"buildIdentifier" : "68a2bbd0048a454d91b3734b5d5dc45e_1558640253",
"startDate" : "2019-05-23T05:52:28.244000Z",
"documentURL" : "",
"detailStepType" : "none"
}
```
</details>


For more information regarding each field, check out the [JSON format documentation](https://github.com/spotify/XCLogParser/blob/master/docs/JSON%20Format.md).

Expand Down
5 changes: 5 additions & 0 deletions Sources/XCLogParser/parser/BuildStep.swift
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,9 @@ public extension BuildStep {
return details
}

func summarize() -> BuildStep {
var noSubSteps = self
noSubSteps.subSteps = [BuildStep]()
return noSubSteps
}
}
3 changes: 3 additions & 0 deletions Sources/XCLogParser/reporter/Reporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Foundation
public enum Reporter: String {
case json
case flatJson
case summaryJson
case chromeTracer
case html

Expand All @@ -14,6 +15,8 @@ public enum Reporter: String {
return JsonReporter()
case .flatJson:
return FlatJsonReporter()
case .summaryJson:
return SummaryJsonReporter()
case .html:
return HtmlReporter()
}
Expand Down
15 changes: 15 additions & 0 deletions Sources/XCLogParser/reporter/SummaryJsonReporter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Foundation

public struct SummaryJsonReporter: LogReporter {

public func report(build: Any, output: ReporterOutput) throws {
guard let steps = build as? BuildStep else {
throw Error.errorCreatingReport("Type not supported \(type(of: build))")
}
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
let json = try encoder.encode(steps.summarize())
try output.write(report: json)
}

}