Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add file and pretty console logging #77

Merged
merged 1 commit into from
Nov 17, 2020

Conversation

Larusso
Copy link
Member

@Larusso Larusso commented Nov 13, 2020

Description

This patch builds on top of the last addition and prepares a foundation for future tasks with some common settings for logging and console printing.

ConsoleSettings

The console settings config object controls the logoutput of xcodebuild to the standart output. The tool is by nature very verbose and does't allow any verbosity levels to be set except to quiten it completely. In the apple development szene is a tool available to help out with that xcpretty. It's main use is to transform the output of xcodebuild and format it in a shorter more human readable format. It also has formatters to reformat unit test output into different formats. The tool is written in ruby which doesn't help us much so I ported it over to groovy xcpretty.groovy. It is not a 100% port as code snippet colering is missing and only the Simple formatter is supported. This extra library is added and used when prettyPrint is enabled in the console settings object. The logfile written to disk is not formatted!

The console settings can be set on the plugin level for all xcodebuild tasks or individual for each task.

xcodebuild.consoleSettings {
    prettyPrint = true // use xcpretty for console output
    useUnicode = true  // use unicode or ascii output
    colorize = "auto"  // colorize output (always, never, auto)
}

The default values are set based on the gradle console settings which can be changed with the commandline switch --console=(auto,plain,rich,verbose) or via gradle property -Dorg.gradle.console=(auto,plain,rich,verbose)

console setting value pretty print enabled unicode enabled colorized
rich
plain
verbose
auto

because of technical issues with java and gradle it was impossible for me to determine a good value if color output should be enabled or not. Normally one checks if the desired output stream is a tty. This is not possible so I set the rich option as the default because that is what normal invocation will fallback to.

Extension config settings

I added a few config values to the XcodeBuildPluginExtion to set the default log directory, archive directory and derived data directory.

Each xcodebuild task, at the moment only XcodeArchive will bind to these values by default and append the task name to the log file or as a sub directory. The common values can be set in the build.gradle script or via environment variable or gradle property.

Changes

  • ADD file and pretty console logging

@Larusso Larusso added this to the API 1.0.0 stabilization milestone Nov 13, 2020
@Larusso Larusso force-pushed the add/file_and_pretty_logging branch 2 times, most recently from fb4e774 to 1bec6b2 Compare November 16, 2020 07:26
Description
===========

This patch builds on top of the last addition and prepares a foundation
for future tasks with some common settings for logging and console
printing.

ConsoleSettings
---------------

The console settings config object controls the logoutput of `xcodebuild`
to the standart output. The tool is by nature very verbose and does't allow
any verbosity levels to be set except to quiten it completely. In the apple
development szene is a tool available to help out with that [xcpretty]. It's
main use is to transform the output of `xcodebuild` and format it in a shorter
more human readable format. It also has formatters to reformat unit test output
into different formats. The tool is written in ruby which doesn't help us
much so I ported it over to groovy [xcpretty.groovy]. It is not a 100%
port as code snippet colering is missing and only the `Simple` formatter is
supported. This extra library is added and used when `prettyPrint` is enabled in
the console settings object. The logfile written to disk is not formatted!

The console settings can be set on the plugin level for all `xcodebuild` tasks
or individual for each task.

```groovy
xcodebuild.consoleSettings {
    prettyPrint = true // use xcpretty for console output
    useUnicode = true  // use unicode or ascii output
    colorize = "auto"  // colorize output (always, never, auto)
}
```

The default values are set based on the gradle console settings which can be changed
with the commandline switch `--console=(auto,plain,rich,verbose)` or via gradle property
`-Dorg.gradle.console=(auto,plain,rich,verbose)`

| console setting value | pretty print enabled | unicode enabled    | colorized          |
| --------------------- | -------------------- | ------------------ | ------------------ |
| rich                  | ✅   | ✅ | ✅ |
| plain                 | ✅   |                    |                    |
| verbose               |                      |                    |                    |
| auto                  | ✅   | ✅ | ✅ |

> because of technical issues with java and gradle it was impossible for me to determine
> a good value if color output should be enabled or not. Normally one check if the desired
> output stream is a tty. This is not possible so I set the `rich` option as the default
> because that is what normal invocation will fallback to.

Extension config settings
-------------------------

I added a few config values to the `XcodeBuildPluginExtion` to set the
default log directory, archive directory and derived data directory.

Each xcodebuild task, at the moment only `XcodeArchive` will bind to
these values by default and append the task name to the log file or as a
sub directory. The common values can be set in the `build.gradle` script
or via environment variable or gradle property.

Changes
=======

* ![ADD] file and pretty console logging

[xcpretty]:        https://github.com/xcpretty/xcpretty
[xcpretty.groovy]: https://github.com/wooga/xcpretty.groovy/
@Larusso Larusso marked this pull request as ready for review November 16, 2020 09:39
@Larusso Larusso requested a review from Sebu November 16, 2020 09:39
@Larusso Larusso merged commit 4e6664b into release/1.x Nov 17, 2020
@Larusso Larusso deleted the add/file_and_pretty_logging branch November 17, 2020 22:21
@Larusso Larusso linked an issue Nov 27, 2020 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Log files for iOS build process
2 participants