Winston Logging Issue: No Stack Trace Printing
Hi, I'm having an issue with the Winston logging. Once I call smashgg.initialize(), all errors are printing without a stack trace, and nothing I do (whether trying to change logs through the smashgg.js-provided functions or through adding transports to the global Winston object) seems to have any effect whatsoever. Info logs are printing normally. This has hijacked error logging throughout my application, making it almost impossible to debug without any stack traces. I've tried lots of solutions, but the second I call smashgg.initialize() everything switches over to the broken version. I've boiled it down to the simplest possible app, and still the issue persists.
Expected behavior:
Error logs that look like this:
s()
^
ReferenceError: s is not defined
at Object.<anonymous> (/Users/jasper/github/positivity2/index.js:14:1)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)
at internal/main/run_main_module.js:17:11
Actual behavior:
Error logs that look like this:
s is not defined
NOTE: Check your debug log for stack trace
[winston] Attempt to write logs with no transports {"level":"debug"}
Node v12.6.0
index.js
require('dotenv').config()
const smashgg = require('smashgg.js')
const winston = require('winston')
smashgg.disableLog() // has no effect
smashgg.addLog('console', { // also has no effect
level: 'debug',
transports: [new winston.transports.Console()],
})
// if the initialize line below is commented out, the stack trace prints correctly.
// if not, it prints:
// s is not defined
// NOTE: Check your debug log for stack trace
// [winston] Attempt to write logs with no transports {"level":"debug"}"
smashgg.initialize(process.env.SMASHGG_APIKEY)
s()
package.json
...
"dependencies": {
"dotenv": "^8.2.0",
"smashgg.js": "^4.1.10",
"winston": "^3.2.1"
},
...
^ I updated winston to ^3.2.1 just to see if it fixed the issue. The behavior is the same with a fresh install of smashgg.js with no manual Winston updates.
I'll take a look at this very soon. Sorry for the delay.
@midblue I want to apologize. Due to a significant change in my life, I lost track of this project altogether. Sorry you've had to wait so long for support. I've been trying to find others who can step up in my absence. In any case this is back on my radar, but I can't promise I will be able to jump on it immediately
@BrandonCookeDev No worries, I ended up coding my own solution so there's no real need on my end anymore. Obviously, if you want to fix it for future users, that's great :)
If you can could you submit a PR of your solution if you think it's a universal fix?
I didn't feel comfortable in TypeScript, so I actually ended up writing a (much worse) custom version of smashgg.js from scratch that fit my needs better. It's not close enough to this project to make a PR feel relevant.