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

logging - better default colors #1131

Closed
jrob opened this issue Jan 9, 2017 · 15 comments
Closed

logging - better default colors #1131

jrob opened this issue Jan 9, 2017 · 15 comments

Comments

@jrob
Copy link

jrob commented Jan 9, 2017

What You Are Seeing?

The output background is not configurable and overrides the system settings. When the background is set to white the text becomes unreadable.

Choco output screenshot

What is Expected?

Output should not override background settings.

How Did You Get This To Happen? (Steps to Reproduce)

  • I used choco config list arbitrarily.
  • Log output was generated by calling choco config list --verbse --debug
  • Screenshot was generated by calling choco config list

Current colors set for the shell

$colors = [Enum]::GetValues( [ConsoleColor] )
$max = ($colors | foreach { "$_ ".Length } | Measure-Object -Maximum).Maximum
foreach( $color in $colors ) {
    Write-Host (" {0,2} {1,$max} " -f [int]$color,$color) -NoNewline
    Write-Host "$color" -Foreground $color
}

CLI Colors

Windows powershell properties.

Powershell Properties

Output Log

2017-01-09 14:52:05,912 [DEBUG] - Configured chocolatey.infrastructure.logging.log4net.config.xml from assembly choco, Version=0.10.3.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb
2017-01-09 14:52:05,912 [DEBUG] - Configured chocolatey.infrastructure.logging.log4net.config.xml from assembly choco, Version=0.10.3.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb
2017-01-09 14:52:05,933 [DEBUG] - XmlConfiguration is now operational
2017-01-09 14:52:06,107 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\config\chocolatey.config.update".
2017-01-09 14:52:06,116 [INFO ] - ============================================================
2017-01-09 14:52:06,126 [INFO ] - Chocolatey v0.10.3
2017-01-09 14:52:06,144 [DEBUG] - Chocolatey is running on Windows v 10.0.14393.0
2017-01-09 14:52:06,150 [DEBUG] - Attempting to delete file "C:/ProgramData/chocolatey/choco.exe.old".
2017-01-09 14:52:06,155 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\choco.exe.old".
2017-01-09 14:52:06,167 [DEBUG] - Command line not shown - sensitive arguments may have been passed.
2017-01-09 14:52:06,210 [DEBUG] - RemovePendingPackagesTask is now ready and waiting for PreRunMessage.
2017-01-09 14:52:06,222 [DEBUG] - Sending message 'PreRunMessage' out if there are subscribers...
2017-01-09 14:52:06,235 [DEBUG] - [Pending] Removing all pending packages that should not be considered installed...
2017-01-09 14:52:06,401 [DEBUG] - The source '' evaluated to a 'normal' source type
2017-01-09 14:52:06,411 [DEBUG] - 
NOTE: Hiding sensitive configuration data! Please double and triple 
 check to be sure no sensitive data is shown, especially if copying 
 output to a gist for review.
2017-01-09 14:52:06,424 [DEBUG] - Configuration: CommandName='config'|CacheLocation='d:\choco-cache'|
ContainsLegacyPackageInstalls='True'|
CommandExecutionTimeoutSeconds='2700'|WebRequestTimeoutSeconds='30'|
SourceType='normal'|Debug='True'|Verbose='True'|Force='False'|
Noop='False'|HelpRequested='False'|RegularOutput='True'|
QuietOutput='False'|PromptForConfirmation='True'|AcceptLicense='False'|
AllowUnofficialBuild='False'|Input='list'|AllVersions='False'|
SkipPackageInstallProvider='False'|Prerelease='False'|ForceX86='False'|
OverrideArguments='False'|NotSilent='False'|
ApplyPackageParametersToDependencies='False'|
ApplyInstallArgumentsToDependencies='False'|IgnoreDependencies='False'|
AllowMultipleVersions='False'|AllowDowngrade='False'|
ForceDependencies='False'|Information.PlatformType='Windows'|
Information.PlatformVersion='10.0.14393.0'|
Information.PlatformName='Windows'|
Information.ChocolateyVersion='0.10.3.0'|
Information.ChocolateyProductVersion='0.10.3'|
Information.FullName='choco, Version=0.10.3.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb'|
Information.Is64Bit='True'|Information.IsInteractive='True'|
Information.IsUserAdministrator='True'|
Information.IsProcessElevated='True'|
Information.IsLicensedVersion='False'|Information.LicenseType='Foss'|
Features.AutoUninstaller='True'|Features.ChecksumFiles='True'|
Features.AllowEmptyChecksums='False'|
Features.AllowEmptyChecksumsSecure='True'|
Features.FailOnAutoUninstaller='False'|
Features.FailOnStandardError='False'|Features.UsePowerShellHost='True'|
Features.LogEnvironmentValues='False'|Features.VirusCheck='False'|
Features.FailOnInvalidOrMissingLicense='False'|
Features.IgnoreInvalidOptionsSwitches='True'|
Features.UsePackageExitCodes='True'|
Features.UseFipsCompliantChecksums='False'|
Features.ScriptsCheckLastExitCode='False'|
ListCommand.LocalOnly='False'|
ListCommand.IncludeRegistryPrograms='False'|ListCommand.PageSize='25'|
ListCommand.Exact='False'|ListCommand.ByIdOnly='False'|
ListCommand.IdStartsWith='False'|ListCommand.OrderByPopularity='False'|
ListCommand.ApprovedOnly='False'|
ListCommand.DownloadCacheAvailable='False'|
ListCommand.NotBroken='False'|UpgradeCommand.FailOnUnfound='False'|
UpgradeCommand.FailOnNotInstalled='False'|
UpgradeCommand.NotifyOnlyAvailableUpgrades='False'|
NewCommand.AutomaticPackage='False'|
NewCommand.UseOriginalTemplate='False'|SourceCommand.Command='unknown'|
SourceCommand.Priority='0'|FeatureCommand.Command='unknown'|
ConfigCommand.Command='list'|PinCommand.Command='unknown'|
2017-01-09 14:52:06,438 [DEBUG] - _ Chocolatey:ChocolateyConfigCommand - Normal Run Mode _
2017-01-09 14:52:06,447 [INFO ] - Settings
2017-01-09 14:52:06,460 [INFO ] - cacheLocation = d:\choco-cache | Cache location if not TEMP folder.
2017-01-09 14:52:06,472 [INFO ] - containsLegacyPackageInstalls = true | Install has packages installed prior to 0.9.9 series.
2017-01-09 14:52:06,484 [INFO ] - commandExecutionTimeoutSeconds = 2700 | Default timeout for command execution.
2017-01-09 14:52:06,496 [INFO ] - proxy =  | Explicit proxy location.
2017-01-09 14:52:06,505 [INFO ] - proxyUser =  | Optional proxy user.
2017-01-09 14:52:06,516 [INFO ] - proxyPassword =  | Optional proxy password. Encrypted.
2017-01-09 14:52:06,524 [INFO ] - webRequestTimeoutSeconds = 30 | Default timeout for web requests. Available in 0.9.10+.
2017-01-09 14:52:06,534 [INFO ] - 
2017-01-09 14:52:06,544 [INFO ] - Sources
2017-01-09 14:52:06,555 [INFO ] - chocolatey - https://chocolatey.org/api/v2/ | Priority 0.
2017-01-09 14:52:06,565 [INFO ] - 
2017-01-09 14:52:06,575 [INFO ] - NOTE: Use choco source to interact with sources.
2017-01-09 14:52:06,587 [INFO ] - 
2017-01-09 14:52:06,598 [INFO ] - Features
2017-01-09 14:52:06,609 [INFO ] - [x] checksumFiles - Checksum files when pulled in from internet (based on package).
2017-01-09 14:52:06,619 [INFO ] - [x] autoUninstaller - Uninstall from programs and features without requiring an explicit uninstall script.
2017-01-09 14:52:06,631 [INFO ] - [ ] allowGlobalConfirmation - Prompt for confirmation in scripts or bypass.
2017-01-09 14:52:06,642 [INFO ] - [ ] failOnAutoUninstaller - Fail if automatic uninstaller fails.
2017-01-09 14:52:06,652 [INFO ] - [ ] failOnStandardError - Fail if install provider writes to stderr. Available in 0.9.10+.
2017-01-09 14:52:06,663 [INFO ] - [ ] allowEmptyChecksums - Allow packages to have empty/missing checksums for downloaded resources from non-secure locations (HTTP, FTP). Enabling is not recommended if using sources that download resources from the internet. Available in 0.10.0+.
2017-01-09 14:52:06,673 [INFO ] - [x] allowEmptyChecksumsSecure - Allow packages to have empty/missing checksums for downloaded resources from secure locations (HTTPS). Available in 0.10.0+.
2017-01-09 14:52:06,683 [INFO ] - [x] powershellHost - Use Chocolatey's built-in PowerShell host. Available in 0.9.10+.
2017-01-09 14:52:06,693 [INFO ] - [ ] logEnvironmentValues - Log Environment Values - will log values of environment before and after install (could disclose sensitive data). Available in 0.9.10+.
2017-01-09 14:52:06,702 [INFO ] - [ ] virusCheck - Virus Check - perform virus checking on downloaded files. Available in 0.9.10+. Licensed versions only.
2017-01-09 14:52:06,711 [INFO ] - [ ] failOnInvalidOrMissingLicense - Fail On Invalid Or Missing License - allows knowing when a license is expired or not applied to a machine. Available in 0.9.10+.
2017-01-09 14:52:06,720 [INFO ] - [x] ignoreInvalidOptionsSwitches - Ignore Invalid Options/Switches - If a switch or option is passed that is not recognized, should choco fail? Available in 0.9.10+.
2017-01-09 14:52:06,731 [INFO ] - [x] usePackageExitCodes - Use Package Exit Codes - Package scripts can provide exit codes. With this on, package exit codes will be what choco uses for exit when non-zero (this value can come from a dependency package). Chocolatey defines valid exit codes as 0, 1605, 1614, 1641, 3010. With this feature off, choco will exit with a 0 or a 1 (matching previous behavior). Available in 0.9.10+.
2017-01-09 14:52:06,742 [INFO ] - [ ] useFipsCompliantChecksums - Use FIPS Compliant Checksums - Ensure checksumming done by choco uses FIPS compliant algorithms. Not recommended unless required by FIPS Mode. Enabling on an existing installation could have unintended consequences related to upgrades/uninstalls. Available in 0.9.10+.
2017-01-09 14:52:06,753 [INFO ] - [ ] scriptsCheckLastExitCode - Scripts Check $LastExitCode (external commands) - Leave this off unless you absolutely need it while you fix your package scripts  to use `throw 'error message'` or `Set-PowerShellExitCode #` instead of `exit #`. This behavior started in 0.9.10 and produced hard to find bugs. If the last external process exits successfully but with an exit code of not zero, this could cause hard to detect package failures. Available in 0.10.3+. Will be removed in 0.11.0.
2017-01-09 14:52:06,764 [INFO ] - 
2017-01-09 14:52:06,773 [INFO ] - NOTE: Use choco feature to interact with features.
2017-01-09 14:52:06,783 [INFO ] - 
2017-01-09 14:52:06,793 [INFO ] - API Keys
2017-01-09 14:52:06,803 [INFO ] - NOTE: Api Keys are not shown through this command.
 Use choco apikey to interact with API keys.
2017-01-09 14:52:06,813 [DEBUG] - Sending message 'PostRunMessage' out if there are subscribers...
2017-01-09 14:52:06,822 [DEBUG] - Exiting with 0
@ferventcoder
Copy link
Member

Yeah, that looks pretty bad.

@ferventcoder ferventcoder modified the milestones: 0.10.5, 0.10.6, 0.10.7 Mar 30, 2017
@ferventcoder ferventcoder modified the milestones: 0.10.7, 0.10.8 Jun 6, 2017
@ferventcoder ferventcoder modified the milestones: 0.10.8, 0.10.9, 0.10.10 Aug 27, 2017
@ferventcoder ferventcoder removed this from the 0.10.10 milestone Mar 27, 2018
@Zer0t3ch
Copy link

@ferventcoder I don't think completely disabling colored output is much of a solution to this, as color has a place in output; drawing attention to errors for example.

image

I don't have much experience with Powershell, most of my experience is with bash where you can declare a foreground color while leaving the BG color alone. Is that not possible in PS? It seems to be a plausible solution for anyone short of those using a light-background color scheme, in which case a flag of something like --dark-text to use FG colors with more contrast should work just fine.

@gregslu
Copy link

gregslu commented Jun 18, 2018

This is still not fixed... very annoying
It looks that choco will use cmd or powershell background color while installing, and than if you change bg color it will ignore it, and still use the old one

@ferventcoder
Copy link
Member

@viszu @Zer0t3ch you can simply define your own see the comment above at #1131 (comment)

@Zer0t3ch
Copy link

Zer0t3ch commented Jun 20, 2018

@ferventcoder Yes, I saw that, but that doesn't seem to be anything more than a workaround. A consistent deviation in appearance from the default environment (we're not even talking about customized color schemes or anything, although that is where the issue becomes most significant) should not require manual intervention for every single end-user who wants to utilize colored output.

If one day GitHub changes their CSS in a way that accidentally makes all usernames invisible, it would stand to reason that people should report that as a problem. (despite the fact that each individual end-user could override the CSS locally or just not pay attention to usernames) I'm well aware that I'm a nobody, and in both the hypothetical and here: y'all are welcome to ignore me. I just figured I'd contribute my 2¢

@ferventcoder
Copy link
Member

If one day GitHub changes their CSS in a way that accidentally makes all usernames invisible, it would stand to reason that people should report that as a problem. (despite the fact that each individual end-user could override the CSS locally or just not pay attention to usernames)

@Zer0t3ch fair statements - perhaps there is something we can do a better job of doing (or be at least a bit more dynamic based on the environment).

I'm well aware that I'm a nobody, and in both the hypothetical and here: y'all are welcome to ignore me. I just figured I'd contribute my 2¢

I'm going to ignore this statement as you are taking time to provide feedback, which helps improve the product - that sets you above quite a few (thousand/hundred thousand) folks.

@ferventcoder
Copy link
Member

Let's unmark as duplicate and see if we can adjust defaults a bit

@ferventcoder ferventcoder changed the title Command line output ignores system background color configuration logging - better default colors for info Dec 16, 2018
@ferventcoder ferventcoder changed the title logging - better default colors for info logging - better default colors Dec 16, 2018
@ferventcoder
Copy link
Member

In 0.10.12, this will be released - it will inspect the background color being used and make decisions on whether to put a black background behind the text for INFO, WARN, and ERROR level messages. Appreciate the patience, this should definitely be a good addition.

ferventcoder added a commit that referenced this issue Dec 16, 2018
For INFO important messages that use Green, do not
override the background color unless that color conflicts with visibility.
For regular INFO logs, use the same colors already configured in the console.
ferventcoder added a commit that referenced this issue Dec 16, 2018
For warning messages, remove the background color unless that color
conflicts with visibility of the text.
ferventcoder added a commit that referenced this issue Dec 16, 2018
For error messages, remove the background color unless that color
conflicts with the visibility of the text.
ferventcoder added a commit to ferventcoder/choco that referenced this issue Dec 16, 2018
* stable:
  (chocolateyGH-1131) logging: better defaults for ERROR
  (chocolateyGH-1131) logging: better defaults for WARN
  (chocolateyGH-1131) logging: better defaults for INFO
  (chocolateyGH-1665) sign init.ps1 file
  (doc) More info on license next steps
  (chocolateyGH-1503) Warn on incorrectly named license file
  (chocolateyGH-1292) add note on manifest caching
@ferventcoder
Copy link
Member

I didn't grab screenshots while I was going through this unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants