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

libherokubuildpack: Pack output eats log colors #555

Closed
schneems opened this issue Jan 31, 2023 · 2 comments · Fixed by #890
Closed

libherokubuildpack: Pack output eats log colors #555

schneems opened this issue Jan 31, 2023 · 2 comments · Fixed by #890
Assignees
Labels
bug Something isn't working libherokubuildpack

Comments

@schneems
Copy link
Contributor

Running this command:

$ pack build yolo --builder schneems-22 --path /tmp/rails61 --verbose

We should see header colors, but they're eaten by pack. Screenshot:

Screenshot 2023-01-31 at 3 23 10 PM

Notice that the color of [builder] right next to [Installing Ruby] is different. I think what's happening is the color code is somehow being sent before [builder] and it sets it's own color, and then clears it. We get no color because of the clear.

I'm not sure if this is something we can fix here or need to go upstream with a bug report.

@edmorley
Copy link
Member

edmorley commented Jan 31, 2023

This is something that should be fixed/improved (either here or upstream), but as a workaround in the meantime, update to latest pack CLI, since it trusts the heroku/builder:22 image by default. (The reason you are seeing the [builder] prefix is since the builder is being treated as untrusted.)

@edmorley edmorley changed the title Pack output eats libherokubuildpack colors libherokubuildpack: Pack output eats log colors Feb 14, 2024
@edmorley edmorley added the bug Something isn't working label Feb 14, 2024
@edmorley
Copy link
Member

Note: The log module will be removed in the future, since it's been superseded by the build_output module, which handles the case in the OP correctly.

edmorley added a commit that referenced this issue Dec 9, 2024
Fix colour resetting for the `log_*` macros

This fixes some long-standing ANSI colour bugs with the `log_header`, `log_error` and `log_warning` macros. Whilst we soon want to move away to more advanced logging libraries that use the new logging style, there are still many buildpacks using these macros which will benefit short term from these fixes (Procfile, Go, Node.js, JVM, Python, PHP, buildpacks-release-phase, buildpacks-frontend-web).

The logging macros would previously emit output roughly like:

```
<colour>
[Error: Foo]
<reset><colour>Message line one.
Message line two.
```

This was not only missing the final `<reset>`, but also didn't wrap each line individually with colour codes/resets.

This causes issues when lines end up prefixed - such as the Git `remote:` prefix, or when using Pack CLI locally with an untrusted build (which adds the colourised `[builder]` prefixes) or `--timestamps` mode.

For example in this:

```
remote: <colour>
remote: [Error: Foo]
remote: <reset><colour>Message line one.
remote: Message line two.
```

...several of the `remote:`s would inherit the colours.

Instead what we need is:

```
remote:
remote: <colour>[Error: Foo]<reset>
remote: <colour>Message line one.<reset>
remote: <colour>Message line two.<reset>
```

Fixes #555.
Closes #844.
edmorley added a commit that referenced this issue Dec 10, 2024
This fixes some long-standing ANSI colour bugs with the `log_header`, `log_error` and `log_warning` macros. Whilst we soon want to move away to more advanced logging libraries that use the new logging style, there are still many buildpacks using these macros which will benefit short term from these fixes (Procfile, Go, Node.js, JVM, Python, PHP, buildpacks-release-phase, buildpacks-frontend-web).

The logging macros would previously emit output roughly like:

```
<colour>
[Error: Foo]
<reset><colour>Message line one.
Message line two.
```

This was not only missing the final `<reset>`, but also didn't wrap each line individually with colour codes/resets.

This causes issues when lines end up prefixed - such as the Git `remote:` prefix, or when using Pack CLI locally with an untrusted build (which adds the colourised `[builder]` prefixes) or `--timestamps` mode.

For example in this:

```
remote: <colour>
remote: [Error: Foo]
remote: <reset><colour>Message line one.
remote: Message line two.
```

...several of the `remote:`s would inherit the colours.

Instead what we need is:

```
remote:
remote: <colour>[Error: Foo]<reset>
remote: <colour>Message line one.<reset>
remote: <colour>Message line two.<reset>
```

Fixes #555.
Closes #844.
edmorley added a commit that referenced this issue Dec 10, 2024
This fixes some long-standing ANSI colour bugs with the `log_header`,
`log_error` and `log_warning` macros. Whilst we soon want to move away
to more advanced logging libraries that use the new logging style, there
are still many buildpacks using these macros which will benefit short
term from these fixes (Procfile, Go, Node.js, JVM, Python, PHP,
buildpacks-release-phase, buildpacks-frontend-web).

The logging macros would previously emit output roughly like:

```
<colour>
[Error: Foo]
<reset><colour>Message line one.
Message line two.
```

This was not only missing the final `<reset>`, but also didn't wrap
each line individually with colour codes/resets.

This causes issues when lines end up prefixed - such as the Git
`remote:` prefix, or when using Pack CLI locally with an untrusted build
(which adds the colourised `[builder]` prefixes) or `--timestamps` mode.

For example in this:

```
remote: <colour>
remote: [Error: Foo]
remote: <reset><colour>Message line one.
remote: Message line two.
```

...several of the `remote:`s would inherit the colours.

Instead what we need is:

```
remote:
remote: <colour>[Error: Foo]<reset>
remote: <colour>Message line one.<reset>
remote: <colour>Message line two.<reset>
```

Fixes #555.
Closes #844.
edmorley added a commit that referenced this issue Dec 10, 2024
This fixes some long-standing ANSI colour bugs with the `log_header`,
`log_error` and `log_warning` macros. Whilst we soon want to move away
to more advanced logging libraries that use the new logging style, there
are still many buildpacks using these macros which will benefit short
term from these fixes (Procfile, Go, Node.js, JVM, Python, PHP,
buildpacks-release-phase, buildpacks-frontend-web).

The logging macros would previously emit output roughly like:

```
<colour>
[Error: Foo]
<reset><colour>Message line one.
Message line two.
```

This was not only missing the final `<reset>`, but also didn't wrap
each line individually with colour codes/resets.

This causes issues when lines end up prefixed - such as the Git
`remote:` prefix, or when using Pack CLI locally with an untrusted build
(which adds the colourised `[builder]` prefixes) or `--timestamps` mode.

For example in this:

```
remote: <colour>
remote: [Error: Foo]
remote: <reset><colour>Message line one.
remote: Message line two.
```

...several of the `remote:`s would inherit the colours.

Instead what we need is:

```
remote:
remote: <colour>[Error: Foo]<reset>
remote: <colour>Message line one.<reset>
remote: <colour>Message line two.<reset>
```

Fixes #555.
Closes #844.
GUS-W-17400078.
@edmorley edmorley self-assigned this Dec 10, 2024
edmorley added a commit that referenced this issue Dec 10, 2024
This fixes some long-standing ANSI colour bugs with the `log_header`,
`log_error` and `log_warning` macros. Whilst we soon want to move away
to more advanced logging libraries that use the new logging style, there
are still many buildpacks using these macros which will benefit short
term from these fixes (Procfile, Go, Node.js, JVM, Python, PHP,
buildpacks-release-phase, buildpacks-frontend-web).

The logging macros would previously emit output roughly like:

```
<colour>
[Error: Foo]
<reset><colour>Message line one.
Message line two.
```

This was not only missing the final `<reset>`, but also didn't wrap
each line individually with colour codes/resets.

This causes issues when lines end up prefixed - such as the Git
`remote:` prefix, or when using Pack CLI locally with an untrusted build
(which adds the colourised `[builder]` prefixes) or `--timestamps` mode.

For example in this:

```
remote: <colour>
remote: [Error: Foo]
remote: <reset><colour>Message line one.
remote: Message line two.
```

...several of the `remote:`s would inherit the colours.

Instead what we need is:

```
remote:
remote: <colour>[Error: Foo]<reset>
remote: <colour>Message line one.<reset>
remote: <colour>Message line two.<reset>
```

Fixes #555.
Closes #844.
GUS-W-17400078.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working libherokubuildpack
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants