How do you print a value of a variable in the source script?

how do you print a value of a variable in the source script?

Console-like output is not allowed by Painless (see more info as to why that is here). The intended usage is that you emit a value that you are interested in.