Bug: Method names for async functions not showing
See original GitHub issueDescribe the bug When a log is written from an async function it does not have a method name associated with it in the output. This might be an issue with how async/await works - or how I implement so not sure this is a tslog issue or not?
2020-11-18 02:31:14.309.000 INFO [src\main.ts:5 testSync] testSync - Yep
2020-11-18 02:31:14.338.000 INFO [src\main.ts:8] testAsync - Nope
To Reproduce
import { Logger } from 'tslog';
const logger = new Logger();
const testSync = () => {
logger.info('testSync - Yep');
};
const testAsync = async () => {
logger.info('testAsync - Nope');
};
(async () => {
testSync();
await testAsync();
})();
Expected behavior
I would expect the output to show [src\main.ts:8 testAsync]
not just [src\main.ts:8]
.
Screenshots
Additional context Add any other context about the problem here.
Node.js Version v15.2.1
OS incl. Version Windows 10
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Get current method name from async function? - Stack Overflow
Getting the method name by using the caller info attributes is useless in a global error logger because you cannot get the first...
Read more >Don't get burned by missing await Calls for Async Code in ...
I recently got burned in an upgraded ASP.NET Core server application where a missing `await` statement caused wildly inconsistent and ...
Read more >async function - JavaScript - MDN Web Docs - Mozilla
An async function will return a different reference, whereas Promise.resolve returns the same reference if the given value is a promise. It can ......
Read more >Why do people add Async to method names in new code?
I do append "Async" to the name of all my async methods for two ... it's not just any task, it's one that...
Read more >Task asynchronous programming model - Microsoft Learn
Learn when and how to use Task-based async programming, a simplified approach to asynchronous programming in C#.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
No, that was a mistake to target the old version - was converting old projects.
I am going to close this issue because you’ve already found a solution. Let me know if you have a valid use case for targeting
es5
.