Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for logging #199

Closed
Tandashi opened this issue Feb 5, 2023 · 0 comments · Fixed by #227
Closed

Documentation for logging #199

Tandashi opened this issue Feb 5, 2023 · 0 comments · Fixed by #227
Labels
a-docs Relates to the docs package b-documentation Improvements or additions to documentation c-accepted The issue is ready to be worked on

Comments

@Tandashi
Copy link
Contributor

Tandashi commented Feb 5, 2023

Description
Since the Question arose a couple of times in the Discord and asked myself the same thing recently, it would be good
to have a short introduction / guide on how to use the build in logger, so the messages get displayed in the UI.

Doesn't have to be long since there is not much to write about, but I think not a lot of people know that you need to use the useLogger function to get a reference.


Proposed Content
One method of debugging your code or animation flow is using logging messages. For this, motion-canvas has its own build-in way to log messages.

To get a reference to the Logger in motion-canvas you can use the useLogger function:

import { makeScene2D } from '@motion-canvas/2d/lib/scenes';
import { useLogger } from '@motion-canvas/core/lib/utils';

export default makeScene2D(function* (view) {
  const logger = useLogger();
});

On this reference, you are then able to call different functions corresponding to the log level you want to log at.

logger.debug('Just here to debug some code.');
logger.info('All fine just a little info.');
logger.warn('Be careful somethis has gone wrong.');
logger.error('Ups. An error occured.');

These messages get then displayed in the UI under the Console tab on the left side.

@aarthificial aarthificial removed their assignment Feb 6, 2023
@aarthificial aarthificial added b-documentation Improvements or additions to documentation c-accepted The issue is ready to be worked on a-docs Relates to the docs package labels Feb 6, 2023
aarthificial pushed a commit that referenced this issue Feb 15, 2023
Added a logging section in the documentation that
describes the process on how to access and use
the build-in `Logger`.

Closes: #199
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-docs Relates to the docs package b-documentation Improvements or additions to documentation c-accepted The issue is ready to be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants