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

how to change the log's color in XcodeColors #45

Closed
IamAlchemist opened this issue Apr 26, 2016 · 6 comments
Closed

how to change the log's color in XcodeColors #45

IamAlchemist opened this issue Apr 26, 2016 · 6 comments

Comments

@IamAlchemist
Copy link

CleanroomLogger really great, but i wan't to know how to change the color of logs in XcodeColor
According to the document, ColorTable Should be override.

Could anybody give me an example to set it?

the following is my way to override the ColorTable but never worked

        let formatter = XcodeLogFormatter(timestampStyle: .Default, severityStyle: .Xcode, delimiterStyle: nil, showCallSite: true, showCallingThread: false, colorizer: nil)
        let config = XcodeLogConfiguration(minimumSeverity: .Verbose, colorTable: HulkColorTable(), formatter: formatter)
        Log.enable(configuration: config)
@emaloney
Copy link
Owner

Hmmm, just taking a glance at the code you've supplied, it looks like you're doing everything correctly.

Can you verify that XcodeColors is installed correctly & enabled? (If you don't pass your own ColorTable, do you get the expected default colorized output?)

Also, if you wouldn't mind letting me take a look at the HulkColorTable implementation, perhaps I can help. If that's OK with you, I'll reach out via e-mail.

@IamAlchemist
Copy link
Author

IamAlchemist commented May 6, 2016

@emaloney Thank you a lot for replying

This is the implement of HulkColorTable

struct HulkColorTable : ColorTable {
    func foregroundColorForSeverity(severity: LogSeverity) -> Color? {
        switch severity {
        case .Verbose:
            return Color(r: 64, g: 64, b: 64)
        case .Debug:
            return Color(r: 128, g: 128, b: 128)
        case .Info:
            return Color(r: 0, g: 184, b: 254)
        case .Warning:
            return Color(r: 214, g: 134, b: 47)
        case .Error:
            return Color(r: 185, g: 81, b: 46)
        }
    }
}

Although I set configuration with this HulkColorTable, the console still show the error message with the color of (255,0,0)

screen shot 2016-05-06 at 22 10 12

please email me if needed.

thanks a lot

@dev4dev
Copy link

dev4dev commented Aug 5, 2016

The same problem here. It just ignores colors from ColorTable =\ But I have different setup code

        let config = XcodeLogConfiguration(minimumSeverity: .Verbose, debugMode: true, verboseDebugMode: true, logToASL: false, colorizer: XcodeColorsTextColorizer(), colorTable: LoggerColorTable(), filters: [], formatter: XcodeLogFormatter())
        Log.enable(configuration: config)

@emaloney
Copy link
Owner

Thanks a lot for finding the source of this bug, @IamAlchemist.

I have not merged in your PR since I've applied your fix manually (at least to master as of this moment).

I plan to do some more Swift 2.3 / Swift 3.0 work next week and hope to roll the fix out to all branches then.

In the meantime, I'll keep your PR open until you can confirm that the fix on master works as expected for you.

I appreciate you digging in to this. If you have a Twitter handle and let me know what it is, I'll give you a shout-out there, too.

@emaloney
Copy link
Owner

P.S. I should add that the fix is available in CleanroomLogger 2.1.1.

emaloney pushed a commit that referenced this issue Aug 18, 2016
@emaloney
Copy link
Owner

An update: Your fix is also now available on the swift2.3 and swift3 branches. Thanks again!

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

No branches or pull requests

3 participants