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

fix to make the string being attached to coloredLogStream colored again #192

Merged
merged 2 commits into from
May 20, 2022
Merged
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion Sources/Public/Pretty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,14 @@ extension Pretty {
option: Option
) {
let plainString = printer(label, targets, separator, option)
let coloredString = printer(label, targets, separator, option)

let coloredOption: Option = {
var op = option
op.colored = true
return op
}()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't a code like the following suffice?

Suggested change
let coloredOption: Option = {
var op = option
op.colored = true
return op
}()
let coloredOption = option
coloredOption.colored = true

Copy link
Collaborator Author

@sahara-ooga sahara-ooga May 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swift compiler says for the suggested above:

cannot assign to property: 'coloredOption' is a 'let' constant

var is ok:

var coloredOption = option
coloredOption.colored = true

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I wrong.
Use var instead of let is corrected.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YusukeHosonuma
I've refactored in 7582ec5.


let coloredString = printer(label, targets, separator, coloredOption)

// Console
Swift.print(option.colored ? coloredString : plainString)
Expand Down