Skip to content

Commit

Permalink
Merge pull request #974 from Green-Software-Foundation/improve-debug
Browse files Browse the repository at this point in the history
Improve debug logs
  • Loading branch information
narekhovhannisyan authored Aug 21, 2024
2 parents 3ac531b + 0bcc163 commit cc0968c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/common/util/debug-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const logMessagesKeys: (keyof typeof STRINGS)[] = [
'INITIALIZING_PLUGIN',
'LOADING_PLUGIN_FROM_PATH',
'COMPUTING_PIPELINE_FOR_NODE',
'COMPUTING_COMPONENT_PIPELINE',
'REGROUPING',
'OBSERVING',
'MERGING_DEFAULTS_WITH_INPUT_DATA',
Expand Down Expand Up @@ -110,9 +111,12 @@ const debugLog = (level: LogLevel, args: any[], debugMode: boolean) => {

const date = new Date().toISOString();
const plugin = pluginNameManager.currentPluginName;
const formattedMessage = `${level}: ${date}: ${
plugin ? plugin + ': ' : ''
}${args.join(', ')}`;
const isExeption = args[0].includes('**Computing');
const message = `${level}: ${date}: ${plugin ? plugin + ': ' : ''}${args.join(
', '
)}`;

const formattedMessage = isExeption ? args.join(', ') : message;

if (debugMode) {
switch (level) {
Expand Down
2 changes: 2 additions & 0 deletions src/if-run/config/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Note that for the '--output' option you also need to define the output type in y
`Loading ${pluginName} from ${path}`,
COMPUTING_PIPELINE_FOR_NODE: (nodeName: string) =>
`Running compute pipeline: \`${nodeName}\` plugin`,
COMPUTING_COMPONENT_PIPELINE: (component: string) =>
`**Computing \`${component}\` pipeline**`,
REGROUPING: 'Regrouping',
OBSERVING: (nodeName: string) =>
`Running observe pipeline: \`${nodeName}\` plugin`,
Expand Down
2 changes: 2 additions & 0 deletions src/if-run/lib/compute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const {
EMPTY_PIPELINE,
CONFIG_WARN,
COMPUTING_PIPELINE_FOR_NODE,
COMPUTING_COMPONENT_PIPELINE,
REGROUPING,
OBSERVING,
} = STRINGS;
Expand All @@ -27,6 +28,7 @@ const {
*/
const traverse = async (children: any, params: ComputeParams) => {
for (const child in children) {
console.debug(COMPUTING_COMPONENT_PIPELINE(child));
await computeNode(children[child], params);
}
};
Expand Down

0 comments on commit cc0968c

Please sign in to comment.