Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

TypeError: _winston2.default.transports.Logdna is not a constructor #13

Closed
danawoodman opened this issue Jan 11, 2017 · 5 comments
Closed

Comments

@danawoodman
Copy link
Contributor

If you follow the readme to setup with Winston it fails with:

TypeError: _winston2.default.transports.Logdna is not a constructor

Instead, one should import the constructor and use that:

import { WinstonTransport } from 'logdna'

//...

winston.add(WinstonTransport, { /* options */ })

The readme should probably be updated accordingly?

@respectus
Copy link
Contributor

Hi @danawoodman, thanks for the feedback. The assumption was that you would also require the logdna module, when using Winston. I should make this more clear and I have updated the README accordingly. Thanks for helping us improve the documentation!

@danawoodman
Copy link
Contributor Author

@respectus I attempted that as well but it did not fix the issue for me. Are you sure that works?

@respectus
Copy link
Contributor

respectus commented Jan 11, 2017

@danawoodman Yes, I can confirm that this fixes the issue. Would you like to send me the file you are using to test? Here is my configuration:

var logdna = require('logdna');
var winston = require('winston');
var options = {
    key: 'YOUR KEY'
    , hostname: 'test'
    , app: 'anotherApp'
};

// Defaults to false, when true ensures meta object will be searchable
options.index_meta = true;

// Only add this line in order to track exceptions
options.handleExceptions = true;

winston.add(winston.transports.Logdna, options);

winston.log('error', 'Hello again distributed logs');
winston.log('info', 'HELLOHELLO');

// winston.info('TESTEST');
// winston.warn('TESTEST2');

@danawoodman
Copy link
Contributor Author

danawoodman commented Jan 11, 2017

Strange, this is what I get:

/Users/dana/code/myapp/server/node_modules/winston/lib/winston/logger.js:448
  var instance = created ? transport : (new (transport)(options));
                                        ^
TypeError: transport is not a constructor
    at Logger.add (/Users/dana/code/myapp/server/node_modules/winston/lib/winston/logger.js:448:41)
    at Object.winston.(anonymous function) [as add] (/Users/dana/code/myapp/server/node_modules/winston/lib/winston.js:87:34)
    at Object.<anonymous> (/Users/dana/code/myapp/server/app/lib/logger.js:20:9)
    at Module._compile (module.js:541:32)
    at loader (/Users/dana/code/myapp/server/node_modules/babel-register/lib/node.js:146:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/dana/code/myapp/server/node_modules/babel-register/lib/node.js:156:7)
    at Module.load (module.js:456:32)
    at tryModuleLoad (module.js:415:12)
    at Function.Module._load (module.js:407:3)
    at Module.require (module.js:466:17)

Perhaps it has to do with Babel reordering imports or something?

@respectus
Copy link
Contributor

@danawoodman Hmm yes this seems to be a strange issue. If the settings you described above in your first comment work well for you, I'll gladly add it to the README with a note about differing configurations. To investigate the issue further could you confirm you have winston version 2.2.0 running? I found a similar issue here: winstonjs/winston-loggly#42

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants