setCategories static method

LogError setCategories(
  1. String categories, {
  2. String logger = 'Main',
  3. bool clear = false,
})

Sets up categories for the specified logger.

Categories are divided into two types: select and exclude.

  • select categories specify which categories to include, optionally with a minimum level in parentheses. Example: network(warning) selects the network category with a minimum level of warning. If no level is specified, the default level is the lowest, info. Example: core implies core(info).
  • exclude categories specify which categories to exclude, prefixed with a -, optionally with a maximum level in parentheses. Example: -core(error) excludes the core category up to the error level. If no level is specified, the default level is the highest, fatal. Example: -core implies -core(fatal).
  • To selectively remove a category entirely, use the none level. Examples: -core(none) or network(none).

Usage examples:

Log.setCategories('network(warning), core, -core(error)', clear: true);
Log.setCategories('-core(none)');
  • categories: A comma-separated list of categories.
  • logger: The logger name (defaults to "Main").
  • clear: If true, clears both the select and exclude category lists (defaults to false).

Returns: A LogError indicating success or failure.

Implementation

static LogError setCategories(String categories,
    {String logger = 'Main', bool clear = false}) {
  return isCriticalMode
      ? LogError(-5, message: 'is in critical mode')
      : loggerManager.setCategories(categories, logger: logger, clear: clear);
}