Skip to content

FR: optionally log isolate hashCode or custom note/context #2

@dizzib

Description

@dizzib

I am having to write code like this when debugging across isolates:

void _log(String? json) => Log.info('[${Isolate.current.hashCode}] $json');

It would be useful if df_log could support an option like Log.showIsolateHashCode for df_log to show the isolate hashCode, so I could simplify to:

void _log(String? json) => Log.info(json);

I would prefer to use isolate.current.debugName but it shows “main” even across different isolates and there seems to be no way of setting it using pragma.

So ideally df_log would allow me to specify a custom note or context for each isolate like so:

// overlay runs in separate isolate to main app
@pragma("vm:entry-point")
void overlayMain() async {
  Log.context = ‘ISOLATE_OVERLAY’;
  runApp(const view.Overlay());
}

void main() async {
  Log.context = ‘ISOLATE_MAIN’;
  runApp(const App());
}

Then Log.*() would show this context in the logs.

Thanks for this great package!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions