From 003ae0986f5e9788317d5c216410bf821a8a8a5f Mon Sep 17 00:00:00 2001 From: mfranz Date: Fri, 17 Feb 2006 21:24:08 +0000 Subject: [PATCH] add printlog() function that works like SG_LOG(). It takes two arguments: a --log-level and a scalar. Example: printlog("info", "I want more noise"); --- Nasal/globals.nas | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Nasal/globals.nas b/Nasal/globals.nas index ca857b60c..d653b5809 100644 --- a/Nasal/globals.nas +++ b/Nasal/globals.nas @@ -90,3 +90,15 @@ defined = func(sym) { } return 0; } + + +## +# Print log messages in appropriate --log-level. +# Usage: printlog("warn", "..."); +# The underscore hash is used for private variables. +# +_ = {}; +_.dbg_types = { none:0, bulk:1, debug:2, info:3, warn:4, alert:5 }; +_.log_level = _.dbg_types[getprop("/sim/logging/priority")]; +printlog = func(t, m) { if(_.dbg_types[t] >= _.log_level) { print(m) } } +