首页 > 解决方案 > How to log the current function name in Dart?

问题描述

In Objective-C I can log the current function name using __func__ from C99:

NSLog(@"%s", __func__);

How can I do this in Dart?

标签: objective-cfunctionloggingdart

解决方案


You can't in general. Dart does not have such a feature.

What you can do is to take the first line of StackTrace.current.toString() write that in your log. The stack_trace package may help you parse the stack trace. It knows about the most common stack trace formats.


推荐阅读