1
0
Fork 0

Replace printlog by logprint

This commit is contained in:
Henning Stahlke 2020-04-20 16:24:49 +02:00
parent 6078cff6b1
commit fba17e4d34
32 changed files with 124 additions and 136 deletions

View file

@ -1187,8 +1187,8 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
##### remove this code when all references to /sim/auto-coordination are gone
var ac = props.globals.getNode("/sim/auto-coordination");
if (ac != nil) {
printlog("alert",
"WARNING: using deprecated property /sim/auto-coordination. Please change to /controls/flight/auto-coordination" );
logprint(LOG_ALERT, "WARNING: using deprecated property "~
"/sim/auto-coordination. Please change to /controls/flight/auto-coordination");
ac.alias(props.globals.getNode("/controls/flight/auto-coordination", 1));
}
#### end of temporary hack for /sim/auto-coordination

View file

@ -19,10 +19,10 @@
## - searchCmd -> filtering
##
## APIs to be wrapped for each layer:
## printlog(), die(), debug.bt(), benchmark()
## logprint(), die(), debug.bt(), benchmark()
var _MP_dbg_lvl = "debug";
#var _MP_dbg_lvl = "alert";
var _MP_dbg_lvl = LOG_DEBUG;
#var _MP_dbg_lvl = DEV_ALERT;
var makedie = func(prefix) func(msg) globals.die(prefix~" "~msg);
@ -475,7 +475,7 @@ var Symbol = {
var tp = typeof(val);
if(tp != 'scalar'){
val = '';
#printlog("warn", "formattedString: invalid type for "~prop~" (" ~ tp ~ ")");
#logprint(LOG_WARN, "formattedString: invalid type for "~prop~" (" ~ tp ~ ")");
} else {
append(args, val);
}
@ -722,7 +722,7 @@ var DotSym = {
return m;
},
del: func() {
printlog(_MP_dbg_lvl, "DotSym.del()");
logprint(_MP_dbg_lvl, "DotSym.del()");
me.deinit();
call(Symbol.del, nil, me);
me.element.del();
@ -852,7 +852,7 @@ var LineSymbol = {
draw: func() {
if (!me.needs_update) return;
me.callback('draw_before');
printlog(_MP_dbg_lvl, "redrawing a LineSymbol "~me.layer.type);
logprint(_MP_dbg_lvl, "redrawing a LineSymbol "~me.layer.type);
me.element.reset();
var cmds = [];
var coords = [];
@ -879,7 +879,7 @@ var LineSymbol = {
me.callback('draw_after');
},
del: func() {
printlog(_MP_dbg_lvl, "LineSymbol.del()");
logprint(_MP_dbg_lvl, "LineSymbol.del()");
me.deinit();
call(Symbol.del, nil, me);
me.element.del();
@ -1060,7 +1060,7 @@ var MultiSymbolLayer = {
}
},
del: func() {
printlog(_MP_dbg_lvl, "MultiSymbolLayer.del()");
logprint(_MP_dbg_lvl, "MultiSymbolLayer.del()");
foreach (var e; me.list)
e.del();
call(SymbolLayer.del, nil, me);
@ -1094,13 +1094,13 @@ var MultiSymbolLayer = {
},
# Adds a symbol.
onAdded: func(model) {
printlog(_MP_dbg_lvl, "Adding symbol of type "~me.type);
logprint(_MP_dbg_lvl, "Adding symbol of type "~me.type);
if (model == nil) __die("MultiSymbolLayer: Model was nil for layer:"~debug.string(me.type)~ " Hint:check your equality check method!");
append(me.list, Symbol.new(me.type, me.group, me, model));
},
# Removes a symbol.
onRemoved: func(model) {
printlog(_MP_dbg_lvl, "Deleting symbol of type "~me.type);
logprint(_MP_dbg_lvl, "Deleting symbol of type "~me.type);
if (!me.delsym(model)) __die("model not found");
try_aux_method(model, "del");
#call(func model.del(), nil, var err = []); # try...
@ -1121,7 +1121,7 @@ var NavaidSymbolLayer = {
make: func(query) {
#print("Creating searchCmd() for NavaidSymbolLayer:", query);
return func {
printlog(_MP_dbg_lvl, "Running query:", query);
logprint(_MP_dbg_lvl, "Running query:", query);
var range = me.map.getRange();
if (range == nil) return;
return positioned.findWithinRange(me.map.getPosCoord(), range, query);
@ -1177,7 +1177,7 @@ var SingleSymbolLayer = {
}
},
del: func() {
printlog(_MP_dbg_lvl, "SymbolLayer.del()");
logprint(_MP_dbg_lvl, "SymbolLayer.del()");
me.symbol.del();
call(SymbolLayer.del, nil, me);
},
@ -1433,7 +1433,7 @@ var TileLayer = {
}
},
del: func() {
printlog(_MP_dbg_lvl, "SymbolLayer.del()");
logprint(_MP_dbg_lvl, "SymbolLayer.del()");
call(OverlayLayer.del, nil, me);
},
}; # of TileLayer

View file

@ -537,7 +537,7 @@ var Map = {
addLayer: func(factory, type_arg=nil, priority=nil, style=nil, opts=nil, visible=1)
{
if(contains(me.layers, type_arg))
printlog("warn", "addLayer() warning: overwriting existing layer:", type_arg);
logprint(DEV_ALERT, "addLayer() warning: overwriting existing layer:", type_arg);
var options = opts;
# Argument handling
@ -625,7 +625,7 @@ var Map = {
if (predicate == nil or predicate(layer))
layer.update();
}
printlog(_MP_dbg_lvl, "Took "~((systime()-t)*1000)~"ms to update map()");
logprint(_MP_dbg_lvl, "Took "~((systime()-t)*1000)~"ms to update map()");
me.setBool("update", 1); # update any coordinates that changed, to avoid floating labels etc.
return me;
},

View file

@ -276,7 +276,7 @@ draw.marksStyle = {
draw.marksLinear = func(cgroup, orientation, num_marks, interval, style)
{
if (!isa(style, draw.marksStyle)) {
printlog("alert", "draw.marks: invalid style argument.");
logprint(DEV_WARN, "draw.marks: invalid style argument.");
return nil;
}
orientation = chr(string.tolower(orientation[0]));
@ -347,7 +347,7 @@ draw.marksCircular = func(cgroup, radius, interval, phi_start = 0, phi_stop = 36
style = draw.marksStyle.new();
}
if (!isa(style, draw.marksStyle)) {
printlog("info", "draw.marksCircular: invalid style argument");
logprint(DEV_WARN, "draw.marksCircular: invalid style argument");
return nil;
}
# normalize

View file

@ -179,7 +179,7 @@ var AircraftCenter = {
var acft_id = variant;
b.listen("clicked", func
{
printlog("warn", "Switching to aircraft '" ~ acft_id ~ "'");
logprint(LOG_WARN, "Switching to aircraft '" ~ acft_id ~ "'");
fgcommand("switch-aircraft", props.Node.new({"aircraft": acft_id}));
});
launch_bar.addItem(b);

View file

@ -187,7 +187,7 @@ var MessageBox = {
if( io.stat(me._save_path) != nil )
{
printlog("info", "Load dialog selection from '" ~ me._save_path ~ "'");
logprint(LOG_INFO, "Load dialog selection from '" ~ me._save_path ~ "'");
return int(io.readfile(me._save_path));
}
@ -195,7 +195,7 @@ var MessageBox = {
},
_saveSelection: func(sel)
{
printlog("info", "Saving dialog selection to '" ~ me._save_path ~ "'");
logprint(LOG_INFO, "Saving dialog selection to '" ~ me._save_path ~ "'");
# ensure directory exists
os.path.new(me._save_path).create_dir();

View file

@ -22,7 +22,7 @@ var init = func {
var draw = func() {
me.callback('draw_before');
printlog(_MP_dbg_lvl, "redrawing a LineSymbol "~me.layer.type);
logprint(_MP_dbg_lvl, "redrawing a LineSymbol "~me.layer.type);
me.element.reset();
var cmds = [];
var coords = [];

View file

@ -22,7 +22,7 @@ var new = func(layer) {
return m;
};
var del = func() {
printlog(_MP_dbg_lvl, "VOR.lcontroller.del()");
logprint(_MP_dbg_lvl, "VOR.lcontroller.del()");
foreach (var l; me.listeners)
removelistener(l);
};

View file

@ -43,10 +43,10 @@ var del = func() {
};
var searchCmd = func() {
printlog(_MP_dbg_lvl, "Running query: FLT");
logprint(_MP_dbg_lvl, "Running query: FLT");
var hist = aircraft.history();
var path = hist.pathForHistory(1000);
printlog(_MP_dbg_lvl, "FLT size: "~size(path));
logprint(_MP_dbg_lvl, "FLT size: "~size(path));
while (size(me.models) <= me.active_path) append(me.models, []);
for (var i=size(me.models[me.active_path]); i<size(path); i+=1)
me.layer.append(me.active_path, path[i], me.models[me.active_path]);

View file

@ -50,7 +50,7 @@ var last_result = [];
var searchCmd = func {
# FIXME: do we return the current route even if it isn't active?
printlog(_MP_dbg_lvl, "Running query: ", name);
logprint(_MP_dbg_lvl, "Running query: ", name);
var plans = []; # TODO: multiple flightplans?
var driver = me.route_driver;
driver.update();

View file

@ -83,7 +83,7 @@ var searchCmd = func;
var searchCmd_default = func {
# TODO: this would be a good candidate for splitting across frames
printlog(_MP_dbg_lvl, "Doing query: "~name);
logprint(_MP_dbg_lvl, "Doing query: "~name);
if (me.map.getRange() == nil) return;
@ -105,7 +105,7 @@ var searchCmd_default = func {
var (lat,lon) = (t.getValue("position/latitude-deg"),
t.getValue("position/longitude-deg"));
if (lat == nil or lon == nil) {
printlog("alert", "lat/lon was nil for AI node "~t.getPath());
logprint(LOG_ALERT, "lat/lon was nil for AI node "~t.getPath());
continue;
}

View file

@ -40,7 +40,7 @@ var new = func(layer) {
return m;
};
var del = func() {
printlog(_MP_dbg_lvl, name,".lcontroller.del()");
logprint(_MP_dbg_lvl, name,".lcontroller.del()");
foreach (var l; me.listeners)
removelistener(l);
};

View file

@ -40,7 +40,7 @@ var new = func(layer) {
return m;
};
var del = func() {
printlog(_MP_dbg_lvl, name,".lcontroller.del()");
logprint(_MP_dbg_lvl, name,".lcontroller.del()");
foreach (var l; me.listeners)
removelistener(l);
};

View file

@ -33,7 +33,7 @@ var new = func(layer) {
return m;
};
var del = func() {
printlog(_MP_dbg_lvl, name,".lcontroller.del()");
logprint(_MP_dbg_lvl, name,".lcontroller.del()");
foreach (var l; me.listeners)
removelistener(l);
};

View file

@ -79,7 +79,7 @@ var WPT_model = {
};
var searchCmd = func {
printlog(_MP_dbg_lvl, "Running query: "~name);
logprint(_MP_dbg_lvl, "Running query: "~name);
if (!getprop(me.options.active_node)) return [];
var driver = me.route_driver;

View file

@ -38,7 +38,7 @@ var searchCmd_default = func {
# print("WXR running");
if (me.map.getRange() == nil) return;
printlog(_MP_dbg_lvl, "Doing query: "~name);
logprint(_MP_dbg_lvl, "Doing query: "~name);
var results = [];
foreach (var n; props.globals.getNode("/instrumentation/wxradar",1).getChildren("storm")) {

View file

@ -87,7 +87,7 @@ var update_layers = func {
l.update();
return;
} else
printlog(_MP_dbg_lvl, "update aircraft position");
logprint(_MP_dbg_lvl, "update aircraft position");
var (x,y,z) = pos.xyz();
me._pos.set_xyz(x,y,z);
me._time = time;

View file

@ -376,7 +376,7 @@ var NavDisplay = {
if(!layer['isMapStructure']) # set up an old INEFFICIENT and SLOW layer
the_layer = me.layers[layer.name] = canvas.MAP_LAYERS[layer.name].new( me.map, layer.name, controller );
else {
printlog(canvas._MP_dbg_lvl, "Setting up MapStructure-based layer for ND, name:", layer.name);
logprint(canvas._MP_dbg_lvl, "Setting up MapStructure-based layer for ND, name:", layer.name);
var opt = me.options != nil and me.options[layer.name] != nil ? me.options[layer.name] : nil;
if (opt == nil and contains(layer, 'options'))
opt = layer.options;
@ -410,7 +410,7 @@ var NavDisplay = {
l.predicate = func {
var t = systime();
call(_predicate, arg, me);
printlog(canvas._MP_dbg_lvl, "Took "~((systime()-t)*1000)~"ms to update layer "~l.name);
logprint(canvas._MP_dbg_lvl, "Took "~((systime()-t)*1000)~"ms to update layer "~l.name);
}
})();
}
@ -795,7 +795,7 @@ var NavDisplay = {
me.symbols['status.arpt'].setVisible( me.get_switch('toggle_airports') and me.in_mode('toggle_display_mode', ['MAP']));
me.symbols['status.sta'].setVisible( me.get_switch('toggle_stations') and me.in_mode('toggle_display_mode', ['MAP']));
# Okay, _how_ do we hook this up with FGPlot?
printlog(canvas._MP_dbg_lvl, "Total ND update took "~((systime()-_time)*100)~"ms");
logprint(canvas._MP_dbg_lvl, "Total ND update took "~((systime()-_time)*100)~"ms");
setprop("/instrumentation/navdisplay["~ NavDisplay.id ~"]/update-ms", systime() - _time);
} # of update() method (50% of our file ...seriously?)
};

View file

@ -22,10 +22,10 @@ var parsesvg = func(group, path, options = nil)
die("File not found: "~path);
path = file_path;
var _printlog = printlog;
var printlog = func(level, msg)
var logpr = func(level, msg)
{
_printlog(level, "parsesvg: " ~ msg ~ " [path='" ~ path ~ "']");
logprint(level, "parsesvg: "~msg~" [path='"~ path~"']");
};
var custom_font_mapper = options['font-mapper'];
@ -98,7 +98,7 @@ var parsesvg = func(group, path, options = nil)
cur_clip['x'] + cur_clip['width'], cur_clip['y'] + cur_clip['height']);
}
else {
printlog("warn", "Invalid or unsupported clip for element '" ~ id ~ "'");
logpr(LOG_WARN, "Invalid or unsupported clip for element '" ~ id ~ "'");
}
cur_clip = nil;
}
@ -192,13 +192,12 @@ var parsesvg = func(group, path, options = nil)
if( size(values) == 6 )
stack[-1].createTransform(values);
else
printlog(
"warn",
logpr(LOG_WARN,
"Invalid arguments to matrix transform: " ~ debug.string(values, 0)
);
}
else
printlog("warn", "Unknown transform type: '" ~ type ~ "'");
logpr(LOG_WARN, "Unknown transform type: '" ~ type ~ "'");
}
};
@ -278,19 +277,17 @@ var parsesvg = func(group, path, options = nil)
args[i + 6] );
}
if( math.mod(size(args), 7) > 0 )
printlog(
"warn",
"Invalid number of coords for cmd 'a' "
~ "(" ~ size(args) ~ " mod 7 != 0)"
);
if( math.mod(size(args), 7) > 0 ) {
logpr(LOG_WARN, "Invalid number of coords for cmd 'a' ("~
size(args)~" mod 7 != 0)");
}
}
else
{
var cmd_vg = cmd_map[cmd];
if( cmd_vg == nil )
{
printlog("warn", "command not found: '" ~ cmd ~ "'");
logpr(LOG_WARN, "command not found: '" ~ cmd ~ "'");
continue;
}
@ -312,10 +309,8 @@ var parsesvg = func(group, path, options = nil)
}
if( math.mod(size(args), num_coords) > 0 )
printlog(
"warn",
"Invalid number of coords for cmd '" ~ cmd ~ "' "
~ "(" ~ size(args) ~ " mod " ~ num_coords ~ " != 0)"
logpr(LOG_WARN,"Invalid number of coords for cmd '" ~ cmd ~ "' ("
~size(args)~" mod "~num_coords~" != 0)"
);
}
}
@ -439,7 +434,7 @@ var parsesvg = func(group, path, options = nil)
}
else
{
printlog("info", "Skipping unknown element in <defs>: <" ~ name ~ ">");
logpr(LOG_INFO, "Skipping unknown element in <defs>: <" ~ name ~ ">");
skip = level;
}
return;
@ -456,7 +451,7 @@ var parsesvg = func(group, path, options = nil)
cur_clip = clip_dict[clip_id];
if( cur_clip == nil )
printlog("warn", "Clip not found: '" ~ clip_id ~ "'");
logpr(LOG_WARN, "Clip not found: '" ~ clip_id ~ "'");
}
if( style['display'] == 'none' )
@ -565,11 +560,11 @@ var parsesvg = func(group, path, options = nil)
{
var ref = attr["xlink:href"];
if( ref == nil or size(ref) < 2 or ref[0] != `#` )
return printlog("warn", "Invalid or missing href: '" ~ ref ~ "'");
return logpr(LOG_WARN, "Invalid or missing href: '" ~ ref ~ "'");
var el_src = id_dict[ substr(ref, 1) ];
if( el_src == nil )
return printlog("warn", "Reference to unknown element '" ~ ref ~ "'");
return logpr(LOG_WARN, "Reference to unknown element '" ~ ref ~ "'");
# Create new element and copy sub branch from source node
pushElement(el_src._node.getName(), attr['id']);
@ -591,10 +586,10 @@ var parsesvg = func(group, path, options = nil)
# by adding another backslash - otherwise parse error anywhere below
if (ref == nil or find("\\", ref) > -1)
{
return printlog("info", "Invalid or missing href in image tag: '" ~ ref ~ "'");
return logpr(LOG_INFO, "Invalid or missing href in image tag: '" ~ ref ~ "'");
}
if (substr(ref, 0, 5) == "data:") {
return printlog("info", "Unsupported embedded image");
return logpr(LOG_INFO, "Unsupported embedded image");
}
elsif (substr(ref, 0, 5) != "file:") {
# absolute paths seem to start with "file:"
@ -614,7 +609,7 @@ var parsesvg = func(group, path, options = nil)
}
else
{
printlog("info", "Skipping unknown element '" ~ name ~ "'");
logpr(LOG_INFO, "Skipping unknown element '" ~ name ~ "'");
skip = level;
return;
}
@ -764,7 +759,7 @@ var parsesvg = func(group, path, options = nil)
msg ~= (i == 1 ? "\n at " : "\n called from: ")
~ err[i] ~ ", line " ~ err[i + 1]
}
printlog("alert", msg ~ "\n ");
logpr(LOG_ALERT, msg ~ "\n ");
return 0;
}

View file

@ -134,8 +134,7 @@ var Tooltip = {
# wrap mapping in 'call' to catch conversion errors
var val_mapped = call(me._remapValue, [val], me, nil, var err = []);
if( size(err) ) {
printlog(
"warn",
logprint(LOG_WARN,
"Tooltip: failed to remap " ~ debug.string(p, 0) ~ ":\n"
~ debug.string(err, 0)
);

View file

@ -1,5 +1,5 @@
var _REPL_dbg_level = "debug";
#var _REPL_dbg_level = "alert";
var _REPL_dbg_level = LOG_DEBUG;
#var _REPL_dbg_level = LOG_ALERT;
var REPL = {
df_status: 0,
@ -42,7 +42,7 @@ var REPL = {
me.current = nil;
printlog(_REPL_dbg_level, "compiling code..."~debug.string(code));
logprint(_REPL_dbg_level, "compiling code..."~debug.string(code));
var fn = call(func compile(code, me.name), nil, var err=[]);
if (size(err)) {
@ -73,7 +73,7 @@ var REPL = {
var str = substr(str, 0, 1);
if (contains(me.brackets, str)) {
append(level, str);
printlog(_REPL_dbg_level, "> level add "~str);
logprint(_REPL_dbg_level, "> level add "~str);
return 1;
} elsif (contains(me.brackets_rev, str)) {
var l = pop(level);
@ -84,7 +84,7 @@ var REPL = {
me.placement.handle_parse_error("bracket mismatch: "~me.brackets[l]~" vs "~str, me.name, line_number);
return nil;
} else {
printlog(_REPL_dbg_level, "< level pop "~str);
logprint(_REPL_dbg_level, "< level pop "~str);
return 1;
}
}
@ -112,9 +112,9 @@ var REPL = {
me.current.last_operator = nil;
if (line[i] == `\\`) {
i += 1; # skip the next character
printlog(_REPL_dbg_level, " skip backslash");
logprint(_REPL_dbg_level, " skip backslash");
} elsif (line[i] == me.current.level[-1][0]) {
printlog(_REPL_dbg_level, "< out of string with "~me.current.level[-1]);
logprint(_REPL_dbg_level, "< out of string with "~me.current.level[-1]);
pop(me.current.level);
}
continue;
@ -127,7 +127,7 @@ var REPL = {
me.current.last_operator = nil;
if (me.current.statement_level == size(me.current.level) and
(line[i] == `;` or line[i] == `,`)) {
printlog(_REPL_dbg_level, "statement ended by ;/,");
logprint(_REPL_dbg_level, "statement ended by ;/,");
me.current.statement = nil;
me.current.statement_level = nil;
} else {
@ -136,13 +136,13 @@ var REPL = {
me.current = nil;
return 0;
} elsif (me.current.statement_level > size(me.current.level)) {
printlog(_REPL_dbg_level, "statement ended by level below");
logprint(_REPL_dbg_level, "statement ended by level below");
# cancel out of statement
me.current.statement = nil;
me.current.statement_level = nil;
} elsif (line[i] == `{`) {
# cancel out of looking for `;`, because we have a real block here
printlog(_REPL_dbg_level, "statement ended by braces");
logprint(_REPL_dbg_level, "statement ended by braces");
me.current.statement = nil;
me.current.statement_level = nil;
}
@ -155,7 +155,7 @@ var REPL = {
(i+size(stmt) >= len
or !string.isalnum(line[i+size(stmt)])
and line[i+size(stmt)] != `_`)) {
printlog(_REPL_dbg_level, "found: "~stmt);
logprint(_REPL_dbg_level, "found: "~stmt);
me.current.statement = stmt;
me.current.statement_level = size(me.current.level);
i += size(stmt)-1;
@ -165,7 +165,7 @@ var REPL = {
} elsif (me._is_str_char(line[i])) {
me.current.last_operator = nil;
append(me.current.level, chr(line[i]));
printlog(_REPL_dbg_level, "> into string with "~me.current.level[-1]);
logprint(_REPL_dbg_level, "> into string with "~me.current.level[-1]);
} else {
var ret = me._handle_level(me.current.level, chr(line[i]), size(me.current.line)+1);
me.current.last_operator = nil;
@ -174,7 +174,7 @@ var REPL = {
elsif (ret == 0) {
foreach (var o; me.operators_binary_unary)
if (line[i] == o[0])
{ me.current.last_operator = o; printlog(_REPL_dbg_level, "found operator "~o); break }
{ me.current.last_operator = o; logprint(_REPL_dbg_level, "found operator "~o); break }
}
}
}
@ -564,18 +564,18 @@ var CanvasPlacement = {
} elsif (modifiers.ctrl) {
if (keyCode == `c`) {
printlog(_REPL_dbg_level, "ctrl+c: "~debug.string(me.input));
logprint(_REPL_dbg_level, "ctrl+c: "~debug.string(me.input));
me.reset_input_from_history();
if( size(me.input) and !clipboard.setText(me.input) )
print("Failed to write to clipboard");
} elsif (keyCode == `x`) {
printlog(_REPL_dbg_level, "ctrl+x");
logprint(_REPL_dbg_level, "ctrl+x");
me.reset_input_from_history();
if( size(me.input) and !clipboard.setText(me.clear_input()) )
print("Failed to write to clipboard");
} elsif (keyCode == `v`) {
var input = clipboard.getText();
printlog(_REPL_dbg_level, "ctrl+v: "~debug.string(input));
logprint(_REPL_dbg_level, "ctrl+v: "~debug.string(input));
me.reset_input_from_history();
var abnormal = func string.iscntrl(input[j]) or (string.isxspace(input[j]) and input[j] != ` `) or !string.isascii(input[j]);
var i=0;
@ -599,13 +599,13 @@ var CanvasPlacement = {
i=j;
}
} elsif (keyCode == `d`) { # ctrl-D/EOF
printlog(_REPL_dbg_level, "EOF");
logprint(_REPL_dbg_level, "EOF");
me.del();
return 1;
} else return 0;
} elsif (key == "Enter") {
printlog(_REPL_dbg_level, "return (key: "~key~", shift: "~modifiers.shift~")");
logprint(_REPL_dbg_level, "return (key: "~key~", shift: "~modifiers.shift~")");
me.reset_input_from_history();
var reset_text = 1;
if (modifiers.shift) {
@ -621,21 +621,21 @@ var CanvasPlacement = {
CanvasPlacement.current_instance = me;
var res = me.repl.get_input();
CanvasPlacement.current_instance = nil;
printlog(_REPL_dbg_level, "return code: "~debug.string(res));
logprint(_REPL_dbg_level, "return code: "~debug.string(res));
}
if (res == -1)
me.continue_line(reset_text:reset_text);
else me.new_prompt();
} elsif (key == "Backspace") { # backspace
printlog(_REPL_dbg_level, "back");
logprint(_REPL_dbg_level, "back");
me.reset_input_from_history();
if (me.remove_char() == nil) return 1; # nothing happened, since the input
# field was blank, but capture the event
me.completion_pos = -1;
} elsif (key == "Up") { # up
printlog(_REPL_dbg_level, "up");
logprint(_REPL_dbg_level, "up");
if (me.curr == 0) return 1;
me.curr -= 1;
if (me.curr == size(me.history))
@ -645,7 +645,7 @@ var CanvasPlacement = {
me.completion_pos = -1;
} elsif (key == "Down") { # down
printlog(_REPL_dbg_level, "down");
logprint(_REPL_dbg_level, "down");
if (me.curr == size(me.history)) return 1;
me.curr += 1;
if (me.curr == size(me.history))
@ -655,12 +655,12 @@ var CanvasPlacement = {
me.completion_pos = -1;
} elsif (key == "Escape") { # escape -> cancel
printlog(_REPL_dbg_level, "esc");
logprint(_REPL_dbg_level, "esc");
me.del();
return 1;
} elsif (key == "Tab") { # tab
printlog(_REPL_dbg_level, "tab");
logprint(_REPL_dbg_level, "tab");
return 0;
me.reset_input_from_history();
if (size(text) and text[0] == `/`) {
@ -668,16 +668,16 @@ var CanvasPlacement = {
}
} elsif (size(key) > 1 or !string.isprint(key[0])) {
printlog(_REPL_dbg_level, "other key: "~key);
logprint(_REPL_dbg_level, "other key: "~key);
return 0; # pass other funny events
} else {
printlog(_REPL_dbg_level, "key: "~key[0]~" (`"~key~"`)");
logprint(_REPL_dbg_level, "key: "~key[0]~" (`"~key~"`)");
me.add_char(key[0]);
me.completion_pos = -1;
}
#printlog(_REPL_dbg_level, " -> "~me.input);
#logprint(_REPL_dbg_level, " -> "~me.input);
me.update();
me.reset_view();

View file

@ -27,7 +27,7 @@ contrailTimer = maketimer(30, updateContrail);
contrailTimer.simulatedTime = 1;
_setlistener("/sim/signals/nasal-dir-initialized", func {
printlog ("debug", "init contrail");
logprint(LOG_INFO, "Init contrail");
props.globals.initNode("environment/pressure-inhg", 1, "DOUBLE");
props.globals.initNode("environment/temperature-degc", 1, "DOUBLE");
props.globals.initNode("environment/contrail", 1, "BOOL");

View file

@ -118,10 +118,8 @@ var setlistener = func(node, fn, init = 0, runtime = 1) {
var id = _setlistener(node, func(chg, lst, mode, is_child) {
fn(props.wrapNode(chg), props.wrapNode(lst), mode, is_child);
}, init, runtime);
if(__.log_level <= 2) {
var c = caller(1);
printf("setting listener #%d in %s, line %s", id, c[2], c[3]);
}
var c = caller();
logprint(LOG_DEBUG, "setting listener #",id," in ",c[2],":",c[3]);
return id;
}
@ -164,17 +162,14 @@ var values = func(hash) {
return vec;
}
# printlog is depricated, use logprint instead
##
# Print log messages in appropriate --log-level.
# Usage: printlog("warn", "...");
# The underscore hash prevents helper functions/variables from
# needlessly polluting the global namespace.
#
__.dbg_types = { none:0, bulk:1, debug:2, info:3, warn:4, alert:5 };
__.log_level = __.dbg_types[getprop("/sim/logging/priority")];
var printlog = func(level) {
if(__.dbg_types[level] >= __.log_level) call(print, arg);
var printlog = func(level, msg...) {
var c = caller();
logprint(LOG_ALERT, "Deprecated printlog() call from ",c[2]~":"~c[3]~
", please use logprint instead.");
logprint([__.dbg_types[level]]~msg);
}

View file

@ -261,7 +261,7 @@ var mcp = {
watchPropertyForLED: func(prop, ledName)
{
if (!contains(me._ledNames, ledName)) {
printlog('warn', 'Unknown GoFlight MCP LED:' ~ ledName);
logprint(LOG_WARN, 'Unknown GoFlight MCP LED:' ~ ledName);
return;
}

View file

@ -48,8 +48,8 @@ var EFIS = {
# object_names: vector of same size and order as display_names, containing
# 3D object names for canvas placement of the DisplayUnits
new: func(display_names, object_names, canvas_settings=nil) {
if (typeof(display_names) != "vector") {
printlog("error", "EFIS.new: 'display_names' not a vector!");
if (!isvec(display_names)) {
logprint(DEV_ALERT, "EFIS.new: 'display_names' not a vector!");
return;
}
var obj = {
@ -63,14 +63,14 @@ var EFIS = {
active_sources: [],
powerN: nil,
};
if (object_names != nil and typeof(object_names) == "vector"
if (object_names != nil and isvec(object_names)
and size(display_names) == size(object_names))
{
foreach (var i; display_names) {
append(obj.active_sources, EFIS.NO_SRC);
}
var settings = obj.defaultcanvas_settings;
if (canvas_settings != nil and typeof(canvas_settings) == "hash") {
if (canvas_settings != nil and ishash(canvas_settings)) {
foreach (var key; keys(canvas_settings)) {
settings[key] = canvas_settings[key];
}
@ -96,7 +96,7 @@ var EFIS = {
#print("setDisplaySource unit "~du_id~" src "~source_id~" prev "~prev_source);
if (prev_source >= 0) {
if (me.source_records[prev_source] == nil)
printlog("error", "_setDisplaySource error: prev: "~prev_source~" #"~size(me.source_records));
logprint(LOG_ALERT, "_setDisplaySource error: prev: "~prev_source~" #"~size(me.source_records));
var n = me.source_records[prev_source].visibleN;
n.setValue(n.getValue() - 1);
}

View file

@ -271,7 +271,7 @@ var MessageSystem = {
addAuralAlert: func(id, filename, volume=1.0, path=nil) {
if (typeof(id) == "hash") {
printlog(5, "First argument to addAuralAlert() must be a string but is a hash. Use addAuralAlerts() to pass all alerts in one hash.");
logprint(DEV_ALERT, "First argument to addAuralAlert() must be a string but is a hash. Use addAuralAlerts() to pass all alerts in one hash.");
}
me.sounds[id] = {
path: (path == nil) ? me.sound_path : path,
@ -284,7 +284,7 @@ var MessageSystem = {
addAuralAlerts: func(alert_hash) {
if (typeof(alert_hash) != "hash") {
print("MessageSystem.addAuralAlerts: parameter must be a hash!");
logprint(DEV_ALERT, "MessageSystem.addAuralAlerts: parameter must be a hash!");
return;
}
me.sounds = alert_hash;

View file

@ -125,8 +125,7 @@ BroadcastChannel.new = func (mpp_path, process,
last_send : 0.0 # For the send queue
};
if (enable_send and (obj.send_node == nil)) {
printlog("warn",
"BroadcastChannel invalid send node.");
logprint(LOG_WARN, "BroadcastChannel invalid send node.");
return nil;
}
setlistener(obj.ONLINE_pp, func {

View file

@ -288,11 +288,11 @@ var createNodeObjectsFromHash = func (property_list, namespace = nil) {
namespace = caller(1)[0];
}
if (typeof(namespace) != "hash") {
printlog("warning", "createNodeObjectsFromHash: Error, namespace argument is not a hash.");
logprint(LOG_WARN, "createNodeObjectsFromHash: Error, namespace argument is not a hash.");
return nil;
}
if (typeof(property_list) != "hash") {
printlog("warning", "createNodeObjectsFromHash: Error, property_list argument is not a hash.");
logprint(LOG_WARN, "createNodeObjectsFromHash: Error, property_list argument is not a hash.");
return nil;
}
foreach (key; keys(property_list)) {
@ -380,7 +380,7 @@ var _cond = func(p) {
if(n == "less-than-equals") return !_cond_cmp(p, 1);
if(n == "greater-than-equals") return !_cond_cmp(p, -1);
if(n == "property") return !!getprop(p.getValue());
printlog("alert", "condition: invalid operator ", n);
logprint(LOG_ALERT, "condition: invalid operator ", n);
dump(p);
return nil;
}
@ -389,7 +389,7 @@ var _cond_cmp = func(p, op) {
var left = p.getChild("property", 0, 0);
if(left != nil) { left = getprop(left.getValue()); }
else {
printlog("alert", "condition: no left value");
logprint(LOG_ALERT, "condition: no left value");
dump(p);
return nil;
}
@ -399,13 +399,13 @@ var _cond_cmp = func(p, op) {
right = p.getChild("value", 0, 0);
if(right != nil) { right = right.getValue(); }
else {
printlog("alert", "condition: no right value");
logprint(LOG_ALERT, "condition: no right value");
dump(p);
return nil;
}
}
if(left == nil or right == nil) {
printlog("alert", "condition: comparing with nil");
logprint(LOG_ALERT, "condition: comparing with nil");
dump(p);
return nil;
}

View file

@ -269,7 +269,7 @@ var DefaultGPSDeleagte = {
me.landingCheck = nil; # delete timer
}
#printlog('info', 'saw current WP changed, now ' ~ me.flightplan.current);
#logprint(LOG_INFO, 'saw current WP changed, now ' ~ me.flightplan.current);
var active = me.flightplan.currentWP();
if (active == nil) return;

View file

@ -561,7 +561,7 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
# map ATC messages to the screen log and to the voice subsystem
var map = func(type, msg, r, g, b, cond = nil) {
printlog("info", "{", type, "} ", msg);
logprint(LOG_INFO, "{", type, "} ", msg);
setprop("/sim/sound/voices/" ~ type, msg);
if (cond == nil or cond())
@ -584,7 +584,7 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
}
m ~= "I say again: " ~ msg;
atclast.setValue(m);
printlog("debug", "ATC_LAST_MESSAGE: ", m);
logprint(LOG_DEBUG, "ATC_LAST_MESSAGE: ", m);
}
}
}

View file

@ -1,6 +1,6 @@
_setlistener("/sim/signals/nasal-dir-initialized", func {
_setlistener("/sim/presets/latitude-deg", func {
printlog("info", "*** NEW LOCATION ***");
setlistener("/sim/presets/latitude-deg", func {
logprint(LOG_INFO, "*** NEW LOCATION ***");
settimer(func {
var typ = getprop("/sim/type");
var lat = getprop("/position/latitude-deg");

View file

@ -205,7 +205,7 @@ var parse_msg = func (source, msg) {
var pos = Binary.decodeCoord(substr(msg, 6));
ignite(pos, 0);
} else {
printlog("alert", "wildfire.nas: Ignored ignite event flood from " ~
logprint(LOG_ALERT, "wildfire.nas: Ignored ignite event flood from " ~
source.getNode("callsign").getValue());
}
mp_last_limited_event[i] = cur_time;
@ -790,7 +790,7 @@ CAFire.load_event_log = func (filename, skip_ahead_until) {
if (!fgcommand("loadxml",
props.Node.new({ filename : filename,
targetnode : logbase }))) {
printlog("alert", "Wildfire ... failed loading '" ~ filename ~ "'");
logprint(LOG_ALERT, "Wildfire ... failed loading '" ~ filename ~ "'");
return;
}
@ -888,7 +888,7 @@ CAFire.update = func {
me.next = 0;
}
if (me.cells_burning > 0) {
printlog("info",
logprint(LOG_INFO,
"Wildfire: generation " ~ me.generation ~ " updating " ~
size(me.remaining_work) ~" / " ~ me.cells_created ~
" created cells. " ~ me.cells_burning ~ " burning cells.");
@ -943,7 +943,7 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
Binary = mp_broadcast.Binary;
# Create configuration properties if they don't exist already.
# Create configuration properties if they do not exist already.
props.globals.initNode(CA_enabled_pp, 1, "BOOL");
setlistener(CA_enabled_pp, func (n) {
if (getprop("/sim/signals/reinit")) return; # Ignore resets.
@ -980,14 +980,14 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
# Determine the skip-ahead-to time, if any.
var time_hack = time_string_to_epoch(getprop(time_hack_pp));
if (time_hack > SimTime.current_time()) {
printlog("alert",
logprint(LOG_ALERT,
"wildfire.nas: Ignored time hack " ~
(SimTime.current_time() - time_hack) ~
" seconds into the future.");
# Skip ahead to current time instead.
time_hack = -1;
} elsif (time_hack > 0) {
printlog("alert",
logprint(LOG_ALERT,
"wildfire.nas: Time hack " ~
(SimTime.current_time() - time_hack) ~
" seconds ago.");
@ -1030,7 +1030,7 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
});
printlog("info", "Wildfire ... initialized.");
logprint(LOG_INFO, "Wildfire ... initialized.");
});
###############################################################################