log function

bool log (
  1. String msg
)

A logging function used during development.

When run on an Android or IPhone host in debug mode it will also determine the location of the log function call and prefix this to the logged message.

If the log function calls are wrapped in an assert statement they will be removed when the app is deployed in production mode. For this reason the log method call return true.

Implementation

bool log(String msg) {
  StackTrace st = StackTrace.current;
  List<String> lines = "$st".split("\n");
  RegExpMatch rem = exp.firstMatch(lines[1]);
  if (rem != null) {
    dev.log("@${rem.group(1)} $msg");
  } else {
    dev.log("devlog $msg");
  }
  return true;
}