BuildShipBBuildShip
Powered by
AbrarA
BuildShip•2y ago•
4 replies
Abrar

Logging witihin NodeLogic

This is probably a very basic Javascript question...

Consulted he documentation and yes there is logging but it is only available (scoped) in the default export function.. I want to log in the other functions... how do I get this to work?

Consider the following:

export default async function (
  { inputData }: NodeInputs, // Access values of node input params
  { logging, env }: NodeScriptOptions,
): NodeOutput {
  /* Log values while executing the node/workflow */
  logging.log(">> Hello From Default!");
  someFunc();
 
  return {}
} 

function someFunc() {
  // This is what i want to do..
  logging.log(">> >> Hello from someFunc()");
  // I keep getting 'logging is not defined' ...
}
export default async function (
  { inputData }: NodeInputs, // Access values of node input params
  { logging, env }: NodeScriptOptions,
): NodeOutput {
  /* Log values while executing the node/workflow */
  logging.log(">> Hello From Default!");
  someFunc();
 
  return {}
} 

function someFunc() {
  // This is what i want to do..
  logging.log(">> >> Hello from someFunc()");
  // I keep getting 'logging is not defined' ...
}


Thanks in advance!
Solution
Hey @Abrar, you can do this by passing the
logging
logging
as a parameter to other functions.

Check this updated code:

export default async function (
  { inputData }: NodeInputs, // Access values of node input params
  { logging, env }: NodeScriptOptions,
): NodeOutput {
  /* Log values while executing the node/workflow */
  logging.log(">> Hello From Default!");
  someFunc(logging);
 
  return {}
} 

function someFunc(logging: NodeScriptOptions["logging"]) {
  // This is what i want to do..
  logging.log(">> >> Hello from someFunc()");
  // I keep getting 'logging is not defined' ...
}
export default async function (
  { inputData }: NodeInputs, // Access values of node input params
  { logging, env }: NodeScriptOptions,
): NodeOutput {
  /* Log values while executing the node/workflow */
  logging.log(">> Hello From Default!");
  someFunc(logging);
 
  return {}
} 

function someFunc(logging: NodeScriptOptions["logging"]) {
  // This is what i want to do..
  logging.log(">> >> Hello from someFunc()");
  // I keep getting 'logging is not defined' ...
}


Hope this helps!
Jump to solution
BuildShip banner
BuildShipJoin
Join founders, builders, devs using Low-code / No-code to create backend, APIs, scheduled Jobs, automation, AI workflows
7,971Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

logging
oneway6026Ooneway6026 / ❓・buildship-help
2y ago
How to view console logs
ZippidyZapZZippidyZap / ❓・buildship-help
2y ago
trouble exporting default function
SleetzaSSleetza / ❓・buildship-help
2y ago
Can we write logs to console without using Log node?
OlisocksOOlisocks / ❓・buildship-help
2y ago