update debug log usage and add fanciness to log printing

This commit is contained in:
Aidan 2020-07-23 12:08:29 -07:00
parent 91498926d5
commit 1f192607b2
No known key found for this signature in database
GPG key ID: 327711E983899316
8 changed files with 27 additions and 25 deletions

View file

@ -17,7 +17,10 @@
package ast
import "gitlab.com/whom/shs/log"
import (
"fmt"
"gitlab.com/whom/shs/log"
)
/* expected function header for any stdlib function
*/
@ -61,8 +64,12 @@ func (f Function) ParseFunction(args *Token) bool {
if i != 0 {
log.Log(log.ERR,
"Incorrect number of arguments",
"eval")
"Incorrect number of arguments",
"eval")
log.Log(log.DEBUG,
fmt.Sprintf("Function %s expects %d arguments. You've provided %d arguments.",
f.Name, f.Args, f.Args - i),
"eval")
return false
}
@ -89,7 +96,7 @@ func (f Function) CallFunction(args *Token, vt VarTable, ft FuncTable) *Token {
func GetFunction(arg string, table FuncTable) *Function {
target, ok := (*table)[arg]
if !ok {
log.Log(log.DEBUG,
log.Log(log.INFO,
"function " + arg + " not found",
"ftable")
return nil