erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.69k stars 55 forks source link

Make debug log outputs neater #93

Closed ytoml closed 2 years ago

ytoml commented 2 years ago

While debug feature is helpful for debugging, there left some boring jobs like:

use erg_common::color::*;
log!("{GREEN}[DEBUG] msg {RESET}");

Currently, debug outputs look like:

スクリーンショット 2022-08-30 11 09 12

Once we forget to end with "msg {RESET}", output are painted in all green and it is a little bit difficult to see. Also, handwritten [DEBUG] is not aligned due to different length of file/line info.

Thus, I introduced these fix in log! macro Changes proposed in this PR:

With these utilities, we can easily write neat logs with:

log!(info "compiler reached {}", fn_name!());
log!(err "error occured in {}!", fn_name!());

and outputs look like:

スクリーンショット 2022-08-30 11 08 20

@mtshiba

mtshiba commented 2 years ago

Pretty good! Thank you!