Open jxstxn1 opened 11 months ago
How do I run your code exactly? When I run it with flutter run
, both in the browser and VM, the "Log ..." buttons don't do anything.
@osa1 I produced the example on an iOS Emulator running from VS Code and reading the Debug Console in there.
I can reproduce the same behavior running on a Browser and reading the Debug Console in VS Code.
However, I can also reproduce your behavior by reading the Browser Console, which is empty by default. If I add verbose
to the levels, I can see the Log being logged as an Object:
I have similar issue from Trace.current(1)
which wraps output of develop.log with LazyTrace
I try to get my StackTraces logged.
It's working fine if I call:
print(Chain.current().terse);
StackTrace
```bash flutter: package:stacktrace_test/main.dart 36:35 HomePage.build.
package:flutter/src/material/ink_well.dart 1183:21 _InkResponseState.handleTap
package:flutter/src/gestures/recognizer.dart 275:24 GestureRecognizer.invokeCallback
package:flutter/src/gestures/tap.dart 652:11 TapGestureRecognizer.handleTapUp
package:flutter/src/gestures/tap.dart 309:5 BaseTapGestureRecognizer._checkUp
package:flutter/src/gestures/tap.dart 242:7 BaseTapGestureRecognizer.handlePrimaryPointer
package:flutter/src/gestures/recognizer.dart 630:9 PrimaryPointerGestureRecognizer.handleEvent
package:flutter/src/gestures/pointer_router.dart 98:12 PointerRouter._dispatch
package:flutter/src/gestures/pointer_router.dart 143:9 PointerRouter._dispatchEventToRoutes.
dart:collection _LinkedHashMapMixin.forEach
package:flutter/src/gestures/pointer_router.dart 141:18 PointerRouter._dispatchEventToRoutes
package:flutter/src/gestures/pointer_router.dart 127:7 PointerRouter.route
package:flutter/src/gestures/binding.dart 488:19 GestureBinding.handleEvent
package:flutter/src/gestures/binding.dart 468:22 GestureBinding.dispatchEvent
package:flutter/src/rendering/binding.dart 439:11 RendererBinding.dispatchEvent
package:flutter/src/gestures/binding.dart 413:7 GestureBinding._handlePointerEventImmediately
package:flutter/src/gestures/binding.dart 376:5 GestureBinding.handlePointerEvent
package:flutter/src/gestures/binding.dart 323:7 GestureBinding._flushPointerEventQueue
package:flutter/src/gestures/binding.dart 292:9 GestureBinding._handlePointerDataPacket
```
If I try it with:
log('', stackTrace: Chain.current().terse)
The outputted StackTrace contains Chain( StackTrace )StackTrace
```bash [log] Chain (package:stacktrace_test/main.dart 43:35 HomePage.build.
package:flutter/src/material/ink_well.dart 1183:21 _InkResponseState.handleTap
package:flutter/src/gestures/recognizer.dart 275:24 GestureRecognizer.invokeCallback
package:flutter/src/gestures/tap.dart 652:11 TapGestureRecognizer.handleTapUp
package:flutter/src/gestures/tap.dart 309:5 BaseTapGestureRecognizer._checkUp
package:flutter/src/gestures/tap.dart 242:7 BaseTapGestureRecognizer.handlePrimaryPointer
package:flutter/src/gestures/recognizer.dart 630:9 PrimaryPointerGestureRecognizer.handleEvent
package:flutter/src/gestures/pointer_router.dart 98:12 PointerRouter._dispatch
package:flutter/src/gestures/pointer_router.dart 143:9 PointerRouter._dispatchEventToRoutes.
dart:collection _LinkedHashMapMixin.forEach
package:flutter/src/gestures/pointer_router.dart 141:18 PointerRouter._dispatchEventToRoutes
package:flutter/src/gestures/pointer_router.dart 127:7 PointerRouter.route
package:flutter/src/gestures/binding.dart 488:19 GestureBinding.handleEvent
package:flutter/src/gestures/binding.dart 468:22 GestureBinding.dispatchEvent
package:flutter/src/rendering/binding.dart 439:11 RendererBinding.dispatchEvent
package:flutter/src/gestures/binding.dart 413:7 GestureBinding._handlePointerEventImmediately
package:flutter/src/gestures/binding.dart 376:5 GestureBinding.handlePointerEvent
package:flutter/src/gestures/binding.dart 323:7 GestureBinding._flushPointerEventQueue
package:flutter/src/gestures/binding.dart 292:9 GestureBinding._handlePointerDataPacket
)
```
Is there any way to get the stacktrace logged without the surrounding
Chain()
?Code Example
```dart import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:stack_trace/stack_trace.dart'; void main() { runApp( const App(), ); } class App extends StatelessWidget { const App({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( home: HomePage(), ); } } class HomePage extends StatelessWidget { const HomePage({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Home Page'), ), body: Column( children: [ ElevatedButton( onPressed: () { final chain = Chain.current(); print(chain.terse); }, child: const Text('Print Chain StackTrace'), ), ElevatedButton( onPressed: () { final chain = Chain.current(); log('Test Message', stackTrace: chain.terse); }, child: const Text('Log Chain StackTrace'), ), ElevatedButton( onPressed: () { final stackTrace = StackTrace.current; log('Test Message', stackTrace: stackTrace); }, child: const Text('Log StackTrace'), ), ], ), ); } } ```