Back

Implement Function Logs (nodejs)

  • 0
  • Self Hosted
elemin67
9 May, 2023, 22:34

How I can use the Logs management for each function execution to put there custom logs like console.log/warn/error.

in front and there is a window for that. How I can use it in my code?

TL;DR
To implement function logs in Node.js, you can use the `console.log()` function. Here's an example of how to do it: ```js module.exports = async (req, res) => { console.log("Hello logs"); res.json({ message: 'Hello from Appwrite!', }); }; ``` This code will log the message "Hello logs" to the console. You can add additional logs using `console.warn()` or `console.error()` if needed. To view the logs for each function execution, you can check the logs in your Appwrite console. It should display all the logs generated by the
Ponguta_
9 May, 2023, 22:38

Logs should work with your normal console.log()

For response you should follow the basic example, and use res.json

TypeScript
module.exports = async (req, res) => {
  console.log("Hello logs");
  res.json({
    message: 'Hello from Appwrite!',
  });
};
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more