Log the superclass name
You can log the name of the superclass like this:
Object.getPrototypeOf(Object.getPrototypeOf(foo)).constructor.name;
see https://stackoverflow.com/a/44251889/675721
Logging the superclass name will not show you which file called instantiated your class, however.
Log the calling file
To do this you should create an log an error.
class Database {
constructor() {
const a = new Error();
console.log(a);
}
}
This will give you a stack trace with all of the file names.
Error
at REPL39:1:23
at Script.runInThisContext (vm.js:132:18)
at REPLServer.defaultEval (repl.js:479:29)
at bound (domain.js:430:14)
at REPLServer.runBound [as eval] (domain.js:443:12)
at REPLServer.onLine (repl.js:809:10)
at REPLServer.emit (events.js:326:22)
at REPLServer.EventEmitter.emit (domain.js:486:12)
at REPLServer.Interface._onLine (readline.js:337:10)
at REPLServer.Interface._line (readline.js:666:8)
Debugger
Neither of these is really the best approach - you should use a debugger to set a breakpoint when the class is instantiated or when the database isn't working and look around to see what is different.