Adding colour to Console.log

Discussion in 'Javascript/Plugin Support' started by Rink27, Aug 26, 2017.

Thread Status:
Not open for further replies.
  1. Rink27

    Rink27 Veteran Veteran

    Messages:
    222
    Likes Received:
    12
    Location:
    Caribbean
    First Language:
    English
    Primarily Uses:
    RMMV
    Is it possible? For example:

    console.log("\C[10]Test");

    outputs Test in the relevant colour. Or is there any other way to make certain console logs to stand out more besides you being creative?
     
    #1
  2. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    623
    Likes Received:
    509
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    @Rink27
    The text codes are only for MV text boxes. They are not available in the console.

    However, you can indeed color the console log messages.
    Here is a small code snippet. Just copy-paste it into a new .js file and import it as a new plugin.
    Code:
    function log(msg, color) {
        console.log("%c" + msg, "color:" + color);
    }
    Then instead of doing
    Code:
    console.log("This is a test!")
    you do
    Code:
    log("This is a test!", "red")
    log("This is a test!", "green")
    log("This is a test!", "blue")
    log("This is a test!", "orange")
    log("This is a test!", "magenta")
     
    #2
    Rink27 likes this.
  3. Sarlecc

    Sarlecc Veteran Veteran

    Messages:
    454
    Likes Received:
    209
    First Language:
    English
    Primarily Uses:
    RMMV
    Also colors in console.log are in css format: see the post by bartburkhardt on this stackoverflow question for an insane example of this.
     
    Last edited: Aug 26, 2017
    #3
    Rink27 likes this.
  4. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,577
    Likes Received:
    1,348
    Location:
    Canada / Qu├ębec
    First Language:
    French
    Primarily Uses:
    RMMV
  5. Rink27

    Rink27 Veteran Veteran

    Messages:
    222
    Likes Received:
    12
    Location:
    Caribbean
    First Language:
    English
    Primarily Uses:
    RMMV
    Thank you very much for all the replies! Hope no one else has anything interesting to add cause I'm gonna report this thread to be closed now.
     
    #5
  6. mlogan

    mlogan Global Moderators Global Mod

    Messages:
    13,732
    Likes Received:
    7,585
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

     
    #6
Thread Status:
Not open for further replies.

Share This Page