activateLogging function

bool activateLogging(
  1. Level level, {
  2. bool colorfulLog = true,
  3. String? logName,
})

Activate logging.

This method can only be called once. Subsequent calls are ignored.

If this call was accepted (i.e. first call), this method returns true, otherwise it returns false.

Implementation

bool activateLogging(log.Level level,
    {bool colorfulLog = true, String? logName}) {
  if (!_loggingActivated) {
    _loggingActivated = true;
    _colorfulLog = colorfulLog;
    if (logName != null) {
      _logName = logName;
    }
    log.Logger.root.level = level;
    _logSubscription =
        log.Logger.root.onRecord.listen(colorfulLog ? _logColored : _log);
    return true;
  }
  return false;
}