hocky's blog

By hocky, 3 years ago, In English

Hello! Today I'm going to show you how to debug with colors in your lovely console ( ^◡^)
I'm sowwy if my engwish is bad (⁄ ⁄>⁄ω⁄<⁄ ⁄)⁄

First Step: wet's see huw it wurksss (*ゝω・)ノ 🍎🍌🍀📘

Okay, so first things first, our terminal has it's own way to interpret color. It basically will escape a certain kind of stuffs and it will interpret it as color for the next stream.

Pwease see this code: 💖💖

Code UωU

2nd Step: wet's make a cwass!

If we wunt to use itt.. Let's make it really easy for us to use!

ColorDebugger Class UωU

Pay attention that I defined endl as \n because we 💗 codeforces. Just kidding, that's because std::endl is a weird stuff that can't be defined with simple generics, and it's really weird, endl is more like a function (it's not but just take it for granted). Next, we got this implementation without defining endl as \n.

ColorDebugger Class Finish UωU

Step 三

Let's see this in action:

Input is in the color dark and output is blue

Beside windows, linux terminal has the same syntax, I awso have twied it.

Pwoof

Don't be confused with bashfast and compileCPP it's basically an alias I've made to access my WSL (Windows Subsystem fow Winux) and to compile C++ code.

ありがとう~! 🐾

I use light mode because it's cwuteeee UωU~~!! 🐾 🐾

  • Vote: I like it
  • +232
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
  Vote: I like it +34 Vote: I do not like it

N-nice tutowial UωU

»
3 years ago, # |
  Vote: I like it +129 Vote: I do not like it

Downvoted because of light theme

»
3 years ago, # |
  Vote: I like it +66 Vote: I do not like it

Light mode UωU 💖💕💓💘💞💝

»
3 years ago, # |
  Vote: I like it +32 Vote: I do not like it

UωU

»
3 years ago, # |
  Vote: I like it +8 Vote: I do not like it

UwU <3

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

(/ =ω=)/ kawaii

Really useful! I'll probably spend the next decade playing with all the different colours.

»
3 years ago, # |
  Vote: I like it -15 Vote: I do not like it

send me the compensation, my eyes are bleeding cuz you showed me the light theme without any warning.

»
3 years ago, # |
  Vote: I like it +45 Vote: I do not like it

uwu twice if you need help

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Cool trick UwU

»
3 years ago, # |
  Vote: I like it +11 Vote: I do not like it

It's so pretty uwu

uwu

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Offtopic:

How you all are inserting emojis? When I try to copy paste the same and preview, it says:

Comment preview error:


Emoji (and other unusual UTF-8 characters) are not supported
»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

What if I want to do the same on Window?

»
3 years ago, # |
  Vote: I like it +3 Vote: I do not like it

colorblinds : 😑

»
3 years ago, # |
  Vote: I like it +8 Vote: I do not like it

I would also suggest a simpler trick, though it is less powerful (you cannot decide to print one thing red and the other thing blue, but it works if you want to separate input and output). You can make an alias x="./a.out | lolcat" and run your code with x; you will have rainbow output.

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

So useful. Those colors will help me debug faster

»
3 years ago, # |
  Vote: I like it +16 Vote: I do not like it

This stackoverflow answer might also be useful to people: https://stackoverflow.com/questions/287871/how-to-print-colored-text-to-the-terminal

In particular the python library rich really shows off what you can do with this stuff.

»
3 years ago, # |
  Vote: I like it +2 Vote: I do not like it

sir what does "uwu" and all the chinese/japanase letter mean?????