objective-c - 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?
解决方案
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.
推荐阅读
- typescript - 基于输入参数的 TypeScript 函数返回类型
- c# - 在每帧调用的 void 中生成随机数
- c# - Console.ReadKey 不可靠
- dart - 在 Flutter 中导航到新屏幕
- python-3.x - 为表中的特定值刮取 Finviz 页面
- html - 为什么我不能只链接到 site.url?
- javascript - 如何在每个json行的开头添加一个编号(格式化)
- python-3.x - 查找字符串中的唯一字母
- java - 自定义 Repo 类使用 JpaRepository 扩展时未发现任何 bean 错误
- java - openjdk8 源码丢失 java_lang_String.h 文件