123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- #!/usr/bin/env python3
- #
- # Just some simple print-to-stderr logging.
- #
- # Written by: Andrew <https://www.andrewyu.org>
- #
- # This is free and unencumbered software released into the public
- # domain.
- #
- # Anyone is free to copy, modify, publish, use, compile, sell, or
- # distribute this software, either in source code form or as a compiled
- # binary, for any purpose, commercial or non-commercial, and by any
- # means.
- #
- # In jurisdictions that recognize copyright laws, the author or authors
- # of this software dedicate any and all copyright interest in the
- # software to the public domain. We make this dedication for the benefit
- # of the public at large and to the detriment of our heirs and
- # successors. We intend this dedication to be an overt act of
- # relinquishment in perpetuity of all present and future rights to this
- # software under copyright law.
- #
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- # OTHER DEALINGS IN THE SOFTWARE.
- import sys
- class textStyle:
- reset = "\033[0m"
- fgBlack = "\033[30m"
- fgBrightBlack = "\033[30;1m"
- bgBlack = "\033[40m"
- bgBrightBlack = "\033[40;1m"
- fgRed = "\033[31m"
- fgBrightRed = "\033[31;1m"
- bgRed = "\033[41m"
- bgBrightRed = "\033[41;1m"
- fgGreen = "\033[32m"
- fgBrightGreen = "\033[32;1m"
- bgGreen = "\033[42m"
- bgBrightGreen = "\033[42;1m"
- fgYellow = "\033[33m"
- fgBrightYellow = "\033[33;1m"
- bgYellow = "\033[43m"
- bgBrightYellow = "\033[43;1m"
- fgBlue = "\033[34m"
- fgBrightBlue = "\033[34;1m"
- bgBlue = "\033[44m"
- bgBrightBlue = "\033[44;1m"
- fgMagenta = "\033[35m"
- fgBrightMagenta = "\033[35;1m"
- bgMagenta = "\033[45m"
- bgBrightMagenta = "\033[45;1m"
- fgCyan = "\033[36m"
- fgBrightCyan = "\033[36;1m"
- bgCyan = "\033[46m"
- bgBrightCyan = "\033[46;1m"
- fgWhite = "\033[37m"
- fgBrightWhite = "\033[37;1m"
- bgWhite = "\033[47m"
- bgBrightWhite = "\033[47;1m"
- def parser(s: str) -> None:
- print(
- textStyle.reset + "[P] " + s + textStyle.reset, file=sys.stdout
- )
- def debug(s: str) -> None:
- print(
- textStyle.fgBrightWhite + "[D] " + s + textStyle.reset,
- file=sys.stdout,
- )
- def info(s: str) -> None:
- print(
- textStyle.fgGreen + "[I] " + s + textStyle.reset,
- file=sys.stdout,
- )
- def note(s: str) -> None:
- print(
- textStyle.fgBrightBlue + "[N] " + s + textStyle.reset,
- file=sys.stdout,
- )
- def caution(s: str) -> None:
- print(
- textStyle.fgBrightYellow + "[C] " + s + textStyle.reset,
- file=sys.stdout,
- )
- def warning(s: str) -> None:
- print(
- textStyle.fgYellow + "[W] " + s + textStyle.reset,
- file=sys.stdout,
- )
- def error(s: str) -> None:
- print(
- textStyle.fgRed + "[E] " + s + textStyle.reset, file=sys.stdout
- )
|