Logger is undefined on global inkdrop object

Hi,

I’m developing a plugin and was wondering if the logger property of th global inkdrop object has moved somewhere or is not available anymore?

When i open the console in Inkdrop and try to manually access logger (inkdrop.logger) it is also undefined. So I presume it has nothing to do with my plugin setup.

Any help would be appreciated on how to log things. Thank you!

Hi Manuel,

Thanks for the question.
The Inkdrop logger is available in inkdrop module, not the global inkdrop variable.
You can use it like so:

const { logger } = require('inkdrop')
logger.info('foo')

Note that it is basically for internal use. For example, logger.debug('foo') outputs nothing in the production builds.
Can you tell me why would you like to use it?

1 Like

Thanks for the answer. So that module is different than the one where the store and notificiations objects e.g. are attached to?

I’m working on a sync/import/export plugin for Todoist. It works quite well so far. I was just wondering where to log some information about what the plugin was doing and how to log when sync errors occured. Such as Todois API responses.

I do notify the user with notifications if something goes wrong but I guess it would be nice to have some sort of log to follow the synchornisatoin trace to be able to say what roughly failed.

1 Like

Ok, I think I was a bit confused.

This is my first plugin and also my first Typescript experience since I wanted to make use of types.

Now if I create a file inkdrop.d.ts with declare module "inkdrop"; the module resolution works since it basically tells Typescript the module exists.

Is that the commonly accepted approach?

Wow, that sounds cool.

It’s correct that you notify the user with notifications for exceptions.
Again, the logger module of Inkdrop is basically for internal use.
Instead, you could use “debug” module for logging your plugin process:

It has type definitions for TypeScript, so you don’t have to worry about that.

Hope that helps!

1 Like

Thank you, that sounds good. I’ll take a look.

1 Like

If you’re interested…

I’m still doing some refactoring, better exception and error management as well as looking into the library you linked to swap out the internal logger. I will probably split parts into separate modules but feature wise it’s pretty much as complete as what Inkdrop and Todoist allow. The Readme is done. I’ll hopefully get around to polish it soon to be able to publish a first version.

1 Like

Wowwww this is so cool!
Can’t wait to share it with people on my Twitter when published :wink:

1 Like

Hi Takuya,
I’ve published a first version (todoist-sync).
I will still rework the code into multiple modules in the coming days but it won’t change the functionality.

I’ve been using it daily for a while now and enjoy working with it.

There is also a super small other plugin for permanently deleting notes by skipping trash I made as well (perma-delete).

Thank you for your help!

1 Like

Hi Manuel!

Thanks for publishing the plugins! A plugin developer license has been applied to you XD
BTW, I’ve tried to use the todoist-sync but got an error on loading:

Error: Cannot find module 'inkdrop-model'
Require stack:
- /Users/nora/Library/Application Support/inkdrop/packages/todoist-sync/lib/todoist-sync-core.js
- /Users/nora/Library/Application Support/inkdrop/packages/todoist-sync/lib/todoist-sync.js
- /Applications/Inkdrop.app/Contents/Resources/app.asar/index.html

I found that the dependencies in package.json looks wrong:

  "dependencies": {
    "@doist/todoist-api-typescript": "^1.5.0",
    "@types/react": "^18.0.11"
  },
  "devDependencies": {
    "@types/node": "^14.11.2",
    "gts": "^3.1.0",
    "inkdrop-model": "^2.7.1",
    "typescript": "^4.7.2"
  },

It should be something like:

  "dependencies": {
    "@doist/todoist-api-typescript": "^1.5.0",
    "inkdrop-model": "^2.7.1"
  },
  "devDependencies": {
    "@types/react": "^18.0.11",
    "@types/node": "^14.11.2",
    "gts": "^3.1.0",
    "typescript": "^4.7.2"
  },

Oh, I’ll fix that. Must’ve accidentally added it to the dev dependencies. And since I symlinked the dev version to my local Inkdrop I probably never realised.

Thanks so much for the dev license!

1 Like

Alright, fixed. Installed the official version from ipm for testing and Inkdrop loads fine now. It was the same issue for both plugins. Thanks for making me aware of that!

Great work, Manuel!
I’ve shared it on my Twitter :smiley:

1 Like