Cosmo / TinyConsole

📱💬🚦 TinyConsole is a micro-console that can help you log and display information inside an iOS application, where having a connection to a development computer is not possible.
MIT License
1.96k stars 89 forks source link

Coloured output #6

Closed jyounus closed 7 years ago

jyounus commented 7 years ago

Hey there,

It would be really cool if it would support coloured text output. So for an error it'll be red, warning orange etc. Colours which I can manually define. Not sure if that would be an overkill, but I would welcome it.

Something like this would be good enough for my purposes (the 'color' parameter being optional and defaulting to nil):

TinyConsole.print("hello", color: UIColor.red)

Thanks

ohitsdaniel commented 7 years ago

I'm on it. :)

ohitsdaniel commented 7 years ago

Would you like the whole line to be coloured or just the text you want to print ?

jyounus commented 7 years ago

Nice! :D

How about having a global var which we can set?

I personally would prefer just the text, so that when it goes onto a new line, I can easily identify it because of the white datetime text.

ohitsdaniel commented 7 years ago

The global var would be the text color of all the text in TinyConsole or what would it do?

jyounus commented 7 years ago

I meant having a global var for your preference if you want to colour the whole line or just the text I provided.

So something like TinyConsole.colorizeWholeLine = true would colour the whole line. If set to false, it would only colour the text I provided.

What do you think? Would be great to give devs the option to select whatever they prefer. :)

Cosmo commented 7 years ago

How about we set the texts as attributed strings?

ohitsdaniel commented 7 years ago

@Cosmo Look at my fork. Implemented printing attributed strings.

Cosmo commented 7 years ago

Oh :D I Just took a look at TinyConsole.swift. I think its sufficient to only have text: String as a valid parameter for texts. By adding the color: UIColor parameter you set the color anyway.

What do you think?

ohitsdaniel commented 7 years ago

I think it would be nice to have a function that also prints NSFormattedStrings since we have implemented the functionality anyways.

You could use your own custom fonts, colours, whatever you like for a really special console output message. 😄