Skip to content

Instantly share code, notes, and snippets.

@laocoi
Last active January 6, 2024 18:35
Show Gist options
  • Select an option

  • Save laocoi/0dd2e5ca1af0558b685ffefacafee126 to your computer and use it in GitHub Desktop.

Select an option

Save laocoi/0dd2e5ca1af0558b685ffefacafee126 to your computer and use it in GitHub Desktop.

Revisions

  1. laocoi revised this gist Jan 6, 2024. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions colorLog.js
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,13 @@
    function colorLog(text, type, getStr = false){
    let str;
    switch (type) {
    case 'e':
    case 'e': // error
    str = '\u001b[38;2;255;0;0m'+text+'\u001b[0m'
    break;
    case 's':
    case 's': // success
    str = '\u001b[38;2;0;255;0m'+text+'\u001b[0m'
    break;
    case 'w':
    case 'w': // warning
    str = '\u001b[38;2;255;140;0m'+text+'\u001b[0m'
    break;
    case 'bold':
    @@ -17,7 +17,7 @@ function colorLog(text, type, getStr = false){
    str = '\u001b[4m'+text+'\u001b[0m'
    break;
    default:

    str = text
    break;
    }
    return getStr ? str : console.log(str)
  2. laocoi renamed this gist Jan 6, 2024. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. laocoi created this gist Jan 6, 2024.
    24 changes: 24 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    function colorLog(text, type, getStr = false){
    let str;
    switch (type) {
    case 'e':
    str = '\u001b[38;2;255;0;0m'+text+'\u001b[0m'
    break;
    case 's':
    str = '\u001b[38;2;0;255;0m'+text+'\u001b[0m'
    break;
    case 'w':
    str = '\u001b[38;2;255;140;0m'+text+'\u001b[0m'
    break;
    case 'bold':
    str = '\u001b[1m'+text+'\u001b[0m'
    break;
    case 'underlined':
    str = '\u001b[4m'+text+'\u001b[0m'
    break;
    default:

    break;
    }
    return getStr ? str : console.log(str)
    }