n8n/packages/cli/src/Logger.ts

121 lines
3.5 KiB
TypeScript
Raw Normal View History

:art: Set up linting and formatting (#2120) * :arrow_up: Upgrade TS to 4.3.5 * :shirt: Add ESLint configs * :art: Add Prettier config * :package: Add deps and commands * :zap: Adjust global .editorconfig to new ruleset * :fire: Remove unneeded local .editorconfig * :package: Update deps in editor-ui * :hammer: Limit Prettier to only TS files * :zap: Add recommended VSCode extensions * :shirt: Fix build * :fire: Remove Vue setting from global config * :zap: Disable prefer-default-export per feedback * :pencil2: Add forgotten divider * :shirt: Disable no-plusplus * :shirt: Disable class-methods-use-this * :pencil2: Alphabetize overrides * :shirt: Add one-var consecutive override * :rewind: Revert one-var consecutive override This reverts commit b9252cf935659ba6d76727ad484a1d3c00008fcc. * 🎨 👕 Lint and format workflow package (#2121) * :art: Format /workflow package * :shirt: Lint /workflow package * :art: Re-format /workflow package * :shirt: Re-lint /workflow package * :pencil2: Fix typo * :zap: Consolidate if-checks * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format node-dev package (#2122) * :art: Format /node-dev package * :zap: Exclude templates from ESLint config This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates. * :shirt: Lint /node-dev package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * 🎨 👕 Lint and format core package (#2123) * :art: Format /core package * :shirt: Lint /core package * :art: Re-format /core package * :shirt: Re-lint /core package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format cli package (#2124) * :art: Format /cli package * :shirt: Exclude migrations from linting * :shirt: Lint /cli package * :art: Re-format /cli package * :shirt: Re-lint /cli package * :shirt: Fix build * :fire: Remove prefer-default-export exceptions * :zap: Update exceptions in ActiveExecutions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 👕 fix lint issues * :wrench: use package specific linter, remove tslint command * :hammer: resolve build issue, sync dependencies * :wrench: change lint command Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
2021-08-29 11:58:11 -07:00
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
:sparkles: Added logging to n8n (#1381) * Added logging to n8n This commit adds logging to n8n using the Winston library. For now, this commit only allows logging to console (default behavior) or file (need to pass in config via environment variables). Other logging methods can be further implemented using hooks. These were skipped for now as it would require adding more dependencies. Logging level is notice by default, meaning no additional messages would be displayed at the moment. Logging level can be set to info or debug as well to enrich the generated logs. The ILogger interface was added to the workflow project as it would make it available for all other projects but the implementation was done on the cli project. * Lint fixes and logging level naming. Also fixed the way we use the logger as it was not working previously * Improvements to logging framework Using appropriate single quotes Improving the way the logger is declared * Improved naming for Log Types * Removed logger global variable, replacing it by a proxy * Add logging to CLI commands * Remove unused GenericHelpers * Changed back some messages to console instead of logger and added npm shortcuts for worker and webhook * Fix typos * Adding basic file rotation to logs as suggested by @mutdmour * Fixed linting issues * Correcting comment to correctly reflect space usage * Added settings for log files rotation * Correcting config type from String to Number * Changed default file settings to number To reflect previous changes to the type * Changed the way log messages are added to be called statically. Also minor naming improvements * Applying latest corrections sent by @ivov * :zap: Some logging improvements * Saving logs to a folder inside n8n home instead of root * Fixed broken tests and linting * Changed some log messages to improve formatting * Adding quotes to names on log messages * Added execution and session IDs to logs. Also removed unnecessary line breaks * :zap: Added file caller to log messages (#1657) This is done using callsites library which already existed in the project as another library's dependency. So in fact it does not add any new dependency. * Adding logs to help debug Salesforce node * :zap: Add function name to logs and add more logs * :zap: Improve some error messages * :zap: Improve some more log messages * :zap: Rename logging env variables to match others Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-05-01 20:43:01 -07:00
import * as winston from 'winston';
:art: Set up linting and formatting (#2120) * :arrow_up: Upgrade TS to 4.3.5 * :shirt: Add ESLint configs * :art: Add Prettier config * :package: Add deps and commands * :zap: Adjust global .editorconfig to new ruleset * :fire: Remove unneeded local .editorconfig * :package: Update deps in editor-ui * :hammer: Limit Prettier to only TS files * :zap: Add recommended VSCode extensions * :shirt: Fix build * :fire: Remove Vue setting from global config * :zap: Disable prefer-default-export per feedback * :pencil2: Add forgotten divider * :shirt: Disable no-plusplus * :shirt: Disable class-methods-use-this * :pencil2: Alphabetize overrides * :shirt: Add one-var consecutive override * :rewind: Revert one-var consecutive override This reverts commit b9252cf935659ba6d76727ad484a1d3c00008fcc. * 🎨 👕 Lint and format workflow package (#2121) * :art: Format /workflow package * :shirt: Lint /workflow package * :art: Re-format /workflow package * :shirt: Re-lint /workflow package * :pencil2: Fix typo * :zap: Consolidate if-checks * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format node-dev package (#2122) * :art: Format /node-dev package * :zap: Exclude templates from ESLint config This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates. * :shirt: Lint /node-dev package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * 🎨 👕 Lint and format core package (#2123) * :art: Format /core package * :shirt: Lint /core package * :art: Re-format /core package * :shirt: Re-lint /core package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format cli package (#2124) * :art: Format /cli package * :shirt: Exclude migrations from linting * :shirt: Lint /cli package * :art: Re-format /cli package * :shirt: Re-lint /cli package * :shirt: Fix build * :fire: Remove prefer-default-export exceptions * :zap: Update exceptions in ActiveExecutions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 👕 fix lint issues * :wrench: use package specific linter, remove tslint command * :hammer: resolve build issue, sync dependencies * :wrench: change lint command Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
2021-08-29 11:58:11 -07:00
import { IDataObject, ILogger, LogTypes } from 'n8n-workflow';
:sparkles: Added logging to n8n (#1381) * Added logging to n8n This commit adds logging to n8n using the Winston library. For now, this commit only allows logging to console (default behavior) or file (need to pass in config via environment variables). Other logging methods can be further implemented using hooks. These were skipped for now as it would require adding more dependencies. Logging level is notice by default, meaning no additional messages would be displayed at the moment. Logging level can be set to info or debug as well to enrich the generated logs. The ILogger interface was added to the workflow project as it would make it available for all other projects but the implementation was done on the cli project. * Lint fixes and logging level naming. Also fixed the way we use the logger as it was not working previously * Improvements to logging framework Using appropriate single quotes Improving the way the logger is declared * Improved naming for Log Types * Removed logger global variable, replacing it by a proxy * Add logging to CLI commands * Remove unused GenericHelpers * Changed back some messages to console instead of logger and added npm shortcuts for worker and webhook * Fix typos * Adding basic file rotation to logs as suggested by @mutdmour * Fixed linting issues * Correcting comment to correctly reflect space usage * Added settings for log files rotation * Correcting config type from String to Number * Changed default file settings to number To reflect previous changes to the type * Changed the way log messages are added to be called statically. Also minor naming improvements * Applying latest corrections sent by @ivov * :zap: Some logging improvements * Saving logs to a folder inside n8n home instead of root * Fixed broken tests and linting * Changed some log messages to improve formatting * Adding quotes to names on log messages * Added execution and session IDs to logs. Also removed unnecessary line breaks * :zap: Added file caller to log messages (#1657) This is done using callsites library which already existed in the project as another library's dependency. So in fact it does not add any new dependency. * Adding logs to help debug Salesforce node * :zap: Add function name to logs and add more logs * :zap: Improve some error messages * :zap: Improve some more log messages * :zap: Rename logging env variables to match others Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-05-01 20:43:01 -07:00
import * as callsites from 'callsites';
import { basename } from 'path';
:art: Set up linting and formatting (#2120) * :arrow_up: Upgrade TS to 4.3.5 * :shirt: Add ESLint configs * :art: Add Prettier config * :package: Add deps and commands * :zap: Adjust global .editorconfig to new ruleset * :fire: Remove unneeded local .editorconfig * :package: Update deps in editor-ui * :hammer: Limit Prettier to only TS files * :zap: Add recommended VSCode extensions * :shirt: Fix build * :fire: Remove Vue setting from global config * :zap: Disable prefer-default-export per feedback * :pencil2: Add forgotten divider * :shirt: Disable no-plusplus * :shirt: Disable class-methods-use-this * :pencil2: Alphabetize overrides * :shirt: Add one-var consecutive override * :rewind: Revert one-var consecutive override This reverts commit b9252cf935659ba6d76727ad484a1d3c00008fcc. * 🎨 👕 Lint and format workflow package (#2121) * :art: Format /workflow package * :shirt: Lint /workflow package * :art: Re-format /workflow package * :shirt: Re-lint /workflow package * :pencil2: Fix typo * :zap: Consolidate if-checks * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format node-dev package (#2122) * :art: Format /node-dev package * :zap: Exclude templates from ESLint config This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates. * :shirt: Lint /node-dev package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * 🎨 👕 Lint and format core package (#2123) * :art: Format /core package * :shirt: Lint /core package * :art: Re-format /core package * :shirt: Re-lint /core package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format cli package (#2124) * :art: Format /cli package * :shirt: Exclude migrations from linting * :shirt: Lint /cli package * :art: Re-format /cli package * :shirt: Re-lint /cli package * :shirt: Fix build * :fire: Remove prefer-default-export exceptions * :zap: Update exceptions in ActiveExecutions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 👕 fix lint issues * :wrench: use package specific linter, remove tslint command * :hammer: resolve build issue, sync dependencies * :wrench: change lint command Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
2021-08-29 11:58:11 -07:00
import config = require('../config');
:sparkles: Added logging to n8n (#1381) * Added logging to n8n This commit adds logging to n8n using the Winston library. For now, this commit only allows logging to console (default behavior) or file (need to pass in config via environment variables). Other logging methods can be further implemented using hooks. These were skipped for now as it would require adding more dependencies. Logging level is notice by default, meaning no additional messages would be displayed at the moment. Logging level can be set to info or debug as well to enrich the generated logs. The ILogger interface was added to the workflow project as it would make it available for all other projects but the implementation was done on the cli project. * Lint fixes and logging level naming. Also fixed the way we use the logger as it was not working previously * Improvements to logging framework Using appropriate single quotes Improving the way the logger is declared * Improved naming for Log Types * Removed logger global variable, replacing it by a proxy * Add logging to CLI commands * Remove unused GenericHelpers * Changed back some messages to console instead of logger and added npm shortcuts for worker and webhook * Fix typos * Adding basic file rotation to logs as suggested by @mutdmour * Fixed linting issues * Correcting comment to correctly reflect space usage * Added settings for log files rotation * Correcting config type from String to Number * Changed default file settings to number To reflect previous changes to the type * Changed the way log messages are added to be called statically. Also minor naming improvements * Applying latest corrections sent by @ivov * :zap: Some logging improvements * Saving logs to a folder inside n8n home instead of root * Fixed broken tests and linting * Changed some log messages to improve formatting * Adding quotes to names on log messages * Added execution and session IDs to logs. Also removed unnecessary line breaks * :zap: Added file caller to log messages (#1657) This is done using callsites library which already existed in the project as another library's dependency. So in fact it does not add any new dependency. * Adding logs to help debug Salesforce node * :zap: Add function name to logs and add more logs * :zap: Improve some error messages * :zap: Improve some more log messages * :zap: Rename logging env variables to match others Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-05-01 20:43:01 -07:00
class Logger implements ILogger {
private logger: winston.Logger;
constructor() {
const level = config.get('logs.level') as string;
:art: Set up linting and formatting (#2120) * :arrow_up: Upgrade TS to 4.3.5 * :shirt: Add ESLint configs * :art: Add Prettier config * :package: Add deps and commands * :zap: Adjust global .editorconfig to new ruleset * :fire: Remove unneeded local .editorconfig * :package: Update deps in editor-ui * :hammer: Limit Prettier to only TS files * :zap: Add recommended VSCode extensions * :shirt: Fix build * :fire: Remove Vue setting from global config * :zap: Disable prefer-default-export per feedback * :pencil2: Add forgotten divider * :shirt: Disable no-plusplus * :shirt: Disable class-methods-use-this * :pencil2: Alphabetize overrides * :shirt: Add one-var consecutive override * :rewind: Revert one-var consecutive override This reverts commit b9252cf935659ba6d76727ad484a1d3c00008fcc. * 🎨 👕 Lint and format workflow package (#2121) * :art: Format /workflow package * :shirt: Lint /workflow package * :art: Re-format /workflow package * :shirt: Re-lint /workflow package * :pencil2: Fix typo * :zap: Consolidate if-checks * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format node-dev package (#2122) * :art: Format /node-dev package * :zap: Exclude templates from ESLint config This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates. * :shirt: Lint /node-dev package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * 🎨 👕 Lint and format core package (#2123) * :art: Format /core package * :shirt: Lint /core package * :art: Re-format /core package * :shirt: Re-lint /core package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format cli package (#2124) * :art: Format /cli package * :shirt: Exclude migrations from linting * :shirt: Lint /cli package * :art: Re-format /cli package * :shirt: Re-lint /cli package * :shirt: Fix build * :fire: Remove prefer-default-export exceptions * :zap: Update exceptions in ActiveExecutions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 👕 fix lint issues * :wrench: use package specific linter, remove tslint command * :hammer: resolve build issue, sync dependencies * :wrench: change lint command Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
2021-08-29 11:58:11 -07:00
// eslint-disable-next-line @typescript-eslint/no-shadow
const output = (config.get('logs.output') as string).split(',').map((output) => output.trim());
:sparkles: Added logging to n8n (#1381) * Added logging to n8n This commit adds logging to n8n using the Winston library. For now, this commit only allows logging to console (default behavior) or file (need to pass in config via environment variables). Other logging methods can be further implemented using hooks. These were skipped for now as it would require adding more dependencies. Logging level is notice by default, meaning no additional messages would be displayed at the moment. Logging level can be set to info or debug as well to enrich the generated logs. The ILogger interface was added to the workflow project as it would make it available for all other projects but the implementation was done on the cli project. * Lint fixes and logging level naming. Also fixed the way we use the logger as it was not working previously * Improvements to logging framework Using appropriate single quotes Improving the way the logger is declared * Improved naming for Log Types * Removed logger global variable, replacing it by a proxy * Add logging to CLI commands * Remove unused GenericHelpers * Changed back some messages to console instead of logger and added npm shortcuts for worker and webhook * Fix typos * Adding basic file rotation to logs as suggested by @mutdmour * Fixed linting issues * Correcting comment to correctly reflect space usage * Added settings for log files rotation * Correcting config type from String to Number * Changed default file settings to number To reflect previous changes to the type * Changed the way log messages are added to be called statically. Also minor naming improvements * Applying latest corrections sent by @ivov * :zap: Some logging improvements * Saving logs to a folder inside n8n home instead of root * Fixed broken tests and linting * Changed some log messages to improve formatting * Adding quotes to names on log messages * Added execution and session IDs to logs. Also removed unnecessary line breaks * :zap: Added file caller to log messages (#1657) This is done using callsites library which already existed in the project as another library's dependency. So in fact it does not add any new dependency. * Adding logs to help debug Salesforce node * :zap: Add function name to logs and add more logs * :zap: Improve some error messages * :zap: Improve some more log messages * :zap: Rename logging env variables to match others Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-05-01 20:43:01 -07:00
this.logger = winston.createLogger({
:art: Set up linting and formatting (#2120) * :arrow_up: Upgrade TS to 4.3.5 * :shirt: Add ESLint configs * :art: Add Prettier config * :package: Add deps and commands * :zap: Adjust global .editorconfig to new ruleset * :fire: Remove unneeded local .editorconfig * :package: Update deps in editor-ui * :hammer: Limit Prettier to only TS files * :zap: Add recommended VSCode extensions * :shirt: Fix build * :fire: Remove Vue setting from global config * :zap: Disable prefer-default-export per feedback * :pencil2: Add forgotten divider * :shirt: Disable no-plusplus * :shirt: Disable class-methods-use-this * :pencil2: Alphabetize overrides * :shirt: Add one-var consecutive override * :rewind: Revert one-var consecutive override This reverts commit b9252cf935659ba6d76727ad484a1d3c00008fcc. * 🎨 👕 Lint and format workflow package (#2121) * :art: Format /workflow package * :shirt: Lint /workflow package * :art: Re-format /workflow package * :shirt: Re-lint /workflow package * :pencil2: Fix typo * :zap: Consolidate if-checks * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format node-dev package (#2122) * :art: Format /node-dev package * :zap: Exclude templates from ESLint config This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates. * :shirt: Lint /node-dev package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * 🎨 👕 Lint and format core package (#2123) * :art: Format /core package * :shirt: Lint /core package * :art: Re-format /core package * :shirt: Re-lint /core package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format cli package (#2124) * :art: Format /cli package * :shirt: Exclude migrations from linting * :shirt: Lint /cli package * :art: Re-format /cli package * :shirt: Re-lint /cli package * :shirt: Fix build * :fire: Remove prefer-default-export exceptions * :zap: Update exceptions in ActiveExecutions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 👕 fix lint issues * :wrench: use package specific linter, remove tslint command * :hammer: resolve build issue, sync dependencies * :wrench: change lint command Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
2021-08-29 11:58:11 -07:00
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
:sparkles: Added logging to n8n (#1381) * Added logging to n8n This commit adds logging to n8n using the Winston library. For now, this commit only allows logging to console (default behavior) or file (need to pass in config via environment variables). Other logging methods can be further implemented using hooks. These were skipped for now as it would require adding more dependencies. Logging level is notice by default, meaning no additional messages would be displayed at the moment. Logging level can be set to info or debug as well to enrich the generated logs. The ILogger interface was added to the workflow project as it would make it available for all other projects but the implementation was done on the cli project. * Lint fixes and logging level naming. Also fixed the way we use the logger as it was not working previously * Improvements to logging framework Using appropriate single quotes Improving the way the logger is declared * Improved naming for Log Types * Removed logger global variable, replacing it by a proxy * Add logging to CLI commands * Remove unused GenericHelpers * Changed back some messages to console instead of logger and added npm shortcuts for worker and webhook * Fix typos * Adding basic file rotation to logs as suggested by @mutdmour * Fixed linting issues * Correcting comment to correctly reflect space usage * Added settings for log files rotation * Correcting config type from String to Number * Changed default file settings to number To reflect previous changes to the type * Changed the way log messages are added to be called statically. Also minor naming improvements * Applying latest corrections sent by @ivov * :zap: Some logging improvements * Saving logs to a folder inside n8n home instead of root * Fixed broken tests and linting * Changed some log messages to improve formatting * Adding quotes to names on log messages * Added execution and session IDs to logs. Also removed unnecessary line breaks * :zap: Added file caller to log messages (#1657) This is done using callsites library which already existed in the project as another library's dependency. So in fact it does not add any new dependency. * Adding logs to help debug Salesforce node * :zap: Add function name to logs and add more logs * :zap: Improve some error messages * :zap: Improve some more log messages * :zap: Rename logging env variables to match others Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-05-01 20:43:01 -07:00
level,
silent: level === 'silent',
:sparkles: Added logging to n8n (#1381) * Added logging to n8n This commit adds logging to n8n using the Winston library. For now, this commit only allows logging to console (default behavior) or file (need to pass in config via environment variables). Other logging methods can be further implemented using hooks. These were skipped for now as it would require adding more dependencies. Logging level is notice by default, meaning no additional messages would be displayed at the moment. Logging level can be set to info or debug as well to enrich the generated logs. The ILogger interface was added to the workflow project as it would make it available for all other projects but the implementation was done on the cli project. * Lint fixes and logging level naming. Also fixed the way we use the logger as it was not working previously * Improvements to logging framework Using appropriate single quotes Improving the way the logger is declared * Improved naming for Log Types * Removed logger global variable, replacing it by a proxy * Add logging to CLI commands * Remove unused GenericHelpers * Changed back some messages to console instead of logger and added npm shortcuts for worker and webhook * Fix typos * Adding basic file rotation to logs as suggested by @mutdmour * Fixed linting issues * Correcting comment to correctly reflect space usage * Added settings for log files rotation * Correcting config type from String to Number * Changed default file settings to number To reflect previous changes to the type * Changed the way log messages are added to be called statically. Also minor naming improvements * Applying latest corrections sent by @ivov * :zap: Some logging improvements * Saving logs to a folder inside n8n home instead of root * Fixed broken tests and linting * Changed some log messages to improve formatting * Adding quotes to names on log messages * Added execution and session IDs to logs. Also removed unnecessary line breaks * :zap: Added file caller to log messages (#1657) This is done using callsites library which already existed in the project as another library's dependency. So in fact it does not add any new dependency. * Adding logs to help debug Salesforce node * :zap: Add function name to logs and add more logs * :zap: Improve some error messages * :zap: Improve some more log messages * :zap: Rename logging env variables to match others Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-05-01 20:43:01 -07:00
});
if (output.includes('console')) {
let format: winston.Logform.Format;
if (['debug', 'verbose'].includes(level)) {
format = winston.format.combine(
winston.format.metadata(),
winston.format.timestamp(),
winston.format.colorize({ all: true }),
:art: Set up linting and formatting (#2120) * :arrow_up: Upgrade TS to 4.3.5 * :shirt: Add ESLint configs * :art: Add Prettier config * :package: Add deps and commands * :zap: Adjust global .editorconfig to new ruleset * :fire: Remove unneeded local .editorconfig * :package: Update deps in editor-ui * :hammer: Limit Prettier to only TS files * :zap: Add recommended VSCode extensions * :shirt: Fix build * :fire: Remove Vue setting from global config * :zap: Disable prefer-default-export per feedback * :pencil2: Add forgotten divider * :shirt: Disable no-plusplus * :shirt: Disable class-methods-use-this * :pencil2: Alphabetize overrides * :shirt: Add one-var consecutive override * :rewind: Revert one-var consecutive override This reverts commit b9252cf935659ba6d76727ad484a1d3c00008fcc. * 🎨 👕 Lint and format workflow package (#2121) * :art: Format /workflow package * :shirt: Lint /workflow package * :art: Re-format /workflow package * :shirt: Re-lint /workflow package * :pencil2: Fix typo * :zap: Consolidate if-checks * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format node-dev package (#2122) * :art: Format /node-dev package * :zap: Exclude templates from ESLint config This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates. * :shirt: Lint /node-dev package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * 🎨 👕 Lint and format core package (#2123) * :art: Format /core package * :shirt: Lint /core package * :art: Re-format /core package * :shirt: Re-lint /core package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format cli package (#2124) * :art: Format /cli package * :shirt: Exclude migrations from linting * :shirt: Lint /cli package * :art: Re-format /cli package * :shirt: Re-lint /cli package * :shirt: Fix build * :fire: Remove prefer-default-export exceptions * :zap: Update exceptions in ActiveExecutions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 👕 fix lint issues * :wrench: use package specific linter, remove tslint command * :hammer: resolve build issue, sync dependencies * :wrench: change lint command Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
2021-08-29 11:58:11 -07:00
// eslint-disable-next-line @typescript-eslint/no-shadow
:sparkles: Added logging to n8n (#1381) * Added logging to n8n This commit adds logging to n8n using the Winston library. For now, this commit only allows logging to console (default behavior) or file (need to pass in config via environment variables). Other logging methods can be further implemented using hooks. These were skipped for now as it would require adding more dependencies. Logging level is notice by default, meaning no additional messages would be displayed at the moment. Logging level can be set to info or debug as well to enrich the generated logs. The ILogger interface was added to the workflow project as it would make it available for all other projects but the implementation was done on the cli project. * Lint fixes and logging level naming. Also fixed the way we use the logger as it was not working previously * Improvements to logging framework Using appropriate single quotes Improving the way the logger is declared * Improved naming for Log Types * Removed logger global variable, replacing it by a proxy * Add logging to CLI commands * Remove unused GenericHelpers * Changed back some messages to console instead of logger and added npm shortcuts for worker and webhook * Fix typos * Adding basic file rotation to logs as suggested by @mutdmour * Fixed linting issues * Correcting comment to correctly reflect space usage * Added settings for log files rotation * Correcting config type from String to Number * Changed default file settings to number To reflect previous changes to the type * Changed the way log messages are added to be called statically. Also minor naming improvements * Applying latest corrections sent by @ivov * :zap: Some logging improvements * Saving logs to a folder inside n8n home instead of root * Fixed broken tests and linting * Changed some log messages to improve formatting * Adding quotes to names on log messages * Added execution and session IDs to logs. Also removed unnecessary line breaks * :zap: Added file caller to log messages (#1657) This is done using callsites library which already existed in the project as another library's dependency. So in fact it does not add any new dependency. * Adding logs to help debug Salesforce node * :zap: Add function name to logs and add more logs * :zap: Improve some error messages * :zap: Improve some more log messages * :zap: Rename logging env variables to match others Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-05-01 20:43:01 -07:00
winston.format.printf(({ level, message, timestamp, metadata }) => {
:art: Set up linting and formatting (#2120) * :arrow_up: Upgrade TS to 4.3.5 * :shirt: Add ESLint configs * :art: Add Prettier config * :package: Add deps and commands * :zap: Adjust global .editorconfig to new ruleset * :fire: Remove unneeded local .editorconfig * :package: Update deps in editor-ui * :hammer: Limit Prettier to only TS files * :zap: Add recommended VSCode extensions * :shirt: Fix build * :fire: Remove Vue setting from global config * :zap: Disable prefer-default-export per feedback * :pencil2: Add forgotten divider * :shirt: Disable no-plusplus * :shirt: Disable class-methods-use-this * :pencil2: Alphabetize overrides * :shirt: Add one-var consecutive override * :rewind: Revert one-var consecutive override This reverts commit b9252cf935659ba6d76727ad484a1d3c00008fcc. * 🎨 👕 Lint and format workflow package (#2121) * :art: Format /workflow package * :shirt: Lint /workflow package * :art: Re-format /workflow package * :shirt: Re-lint /workflow package * :pencil2: Fix typo * :zap: Consolidate if-checks * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format node-dev package (#2122) * :art: Format /node-dev package * :zap: Exclude templates from ESLint config This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates. * :shirt: Lint /node-dev package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * 🎨 👕 Lint and format core package (#2123) * :art: Format /core package * :shirt: Lint /core package * :art: Re-format /core package * :shirt: Re-lint /core package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format cli package (#2124) * :art: Format /cli package * :shirt: Exclude migrations from linting * :shirt: Lint /cli package * :art: Re-format /cli package * :shirt: Re-lint /cli package * :shirt: Fix build * :fire: Remove prefer-default-export exceptions * :zap: Update exceptions in ActiveExecutions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 👕 fix lint issues * :wrench: use package specific linter, remove tslint command * :hammer: resolve build issue, sync dependencies * :wrench: change lint command Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
2021-08-29 11:58:11 -07:00
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
return `${timestamp} | ${level.padEnd(18)} | ${message}${
Object.keys(metadata).length ? ` ${JSON.stringify(metadata)}` : ''
}`;
}),
:sparkles: Added logging to n8n (#1381) * Added logging to n8n This commit adds logging to n8n using the Winston library. For now, this commit only allows logging to console (default behavior) or file (need to pass in config via environment variables). Other logging methods can be further implemented using hooks. These were skipped for now as it would require adding more dependencies. Logging level is notice by default, meaning no additional messages would be displayed at the moment. Logging level can be set to info or debug as well to enrich the generated logs. The ILogger interface was added to the workflow project as it would make it available for all other projects but the implementation was done on the cli project. * Lint fixes and logging level naming. Also fixed the way we use the logger as it was not working previously * Improvements to logging framework Using appropriate single quotes Improving the way the logger is declared * Improved naming for Log Types * Removed logger global variable, replacing it by a proxy * Add logging to CLI commands * Remove unused GenericHelpers * Changed back some messages to console instead of logger and added npm shortcuts for worker and webhook * Fix typos * Adding basic file rotation to logs as suggested by @mutdmour * Fixed linting issues * Correcting comment to correctly reflect space usage * Added settings for log files rotation * Correcting config type from String to Number * Changed default file settings to number To reflect previous changes to the type * Changed the way log messages are added to be called statically. Also minor naming improvements * Applying latest corrections sent by @ivov * :zap: Some logging improvements * Saving logs to a folder inside n8n home instead of root * Fixed broken tests and linting * Changed some log messages to improve formatting * Adding quotes to names on log messages * Added execution and session IDs to logs. Also removed unnecessary line breaks * :zap: Added file caller to log messages (#1657) This is done using callsites library which already existed in the project as another library's dependency. So in fact it does not add any new dependency. * Adding logs to help debug Salesforce node * :zap: Add function name to logs and add more logs * :zap: Improve some error messages * :zap: Improve some more log messages * :zap: Rename logging env variables to match others Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-05-01 20:43:01 -07:00
);
} else {
:art: Set up linting and formatting (#2120) * :arrow_up: Upgrade TS to 4.3.5 * :shirt: Add ESLint configs * :art: Add Prettier config * :package: Add deps and commands * :zap: Adjust global .editorconfig to new ruleset * :fire: Remove unneeded local .editorconfig * :package: Update deps in editor-ui * :hammer: Limit Prettier to only TS files * :zap: Add recommended VSCode extensions * :shirt: Fix build * :fire: Remove Vue setting from global config * :zap: Disable prefer-default-export per feedback * :pencil2: Add forgotten divider * :shirt: Disable no-plusplus * :shirt: Disable class-methods-use-this * :pencil2: Alphabetize overrides * :shirt: Add one-var consecutive override * :rewind: Revert one-var consecutive override This reverts commit b9252cf935659ba6d76727ad484a1d3c00008fcc. * 🎨 👕 Lint and format workflow package (#2121) * :art: Format /workflow package * :shirt: Lint /workflow package * :art: Re-format /workflow package * :shirt: Re-lint /workflow package * :pencil2: Fix typo * :zap: Consolidate if-checks * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format node-dev package (#2122) * :art: Format /node-dev package * :zap: Exclude templates from ESLint config This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates. * :shirt: Lint /node-dev package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * 🎨 👕 Lint and format core package (#2123) * :art: Format /core package * :shirt: Lint /core package * :art: Re-format /core package * :shirt: Re-lint /core package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format cli package (#2124) * :art: Format /cli package * :shirt: Exclude migrations from linting * :shirt: Lint /cli package * :art: Re-format /cli package * :shirt: Re-lint /cli package * :shirt: Fix build * :fire: Remove prefer-default-export exceptions * :zap: Update exceptions in ActiveExecutions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 👕 fix lint issues * :wrench: use package specific linter, remove tslint command * :hammer: resolve build issue, sync dependencies * :wrench: change lint command Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
2021-08-29 11:58:11 -07:00
format = winston.format.printf(({ message }) => message);
:sparkles: Added logging to n8n (#1381) * Added logging to n8n This commit adds logging to n8n using the Winston library. For now, this commit only allows logging to console (default behavior) or file (need to pass in config via environment variables). Other logging methods can be further implemented using hooks. These were skipped for now as it would require adding more dependencies. Logging level is notice by default, meaning no additional messages would be displayed at the moment. Logging level can be set to info or debug as well to enrich the generated logs. The ILogger interface was added to the workflow project as it would make it available for all other projects but the implementation was done on the cli project. * Lint fixes and logging level naming. Also fixed the way we use the logger as it was not working previously * Improvements to logging framework Using appropriate single quotes Improving the way the logger is declared * Improved naming for Log Types * Removed logger global variable, replacing it by a proxy * Add logging to CLI commands * Remove unused GenericHelpers * Changed back some messages to console instead of logger and added npm shortcuts for worker and webhook * Fix typos * Adding basic file rotation to logs as suggested by @mutdmour * Fixed linting issues * Correcting comment to correctly reflect space usage * Added settings for log files rotation * Correcting config type from String to Number * Changed default file settings to number To reflect previous changes to the type * Changed the way log messages are added to be called statically. Also minor naming improvements * Applying latest corrections sent by @ivov * :zap: Some logging improvements * Saving logs to a folder inside n8n home instead of root * Fixed broken tests and linting * Changed some log messages to improve formatting * Adding quotes to names on log messages * Added execution and session IDs to logs. Also removed unnecessary line breaks * :zap: Added file caller to log messages (#1657) This is done using callsites library which already existed in the project as another library's dependency. So in fact it does not add any new dependency. * Adding logs to help debug Salesforce node * :zap: Add function name to logs and add more logs * :zap: Improve some error messages * :zap: Improve some more log messages * :zap: Rename logging env variables to match others Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-05-01 20:43:01 -07:00
}
this.logger.add(
new winston.transports.Console({
format,
:art: Set up linting and formatting (#2120) * :arrow_up: Upgrade TS to 4.3.5 * :shirt: Add ESLint configs * :art: Add Prettier config * :package: Add deps and commands * :zap: Adjust global .editorconfig to new ruleset * :fire: Remove unneeded local .editorconfig * :package: Update deps in editor-ui * :hammer: Limit Prettier to only TS files * :zap: Add recommended VSCode extensions * :shirt: Fix build * :fire: Remove Vue setting from global config * :zap: Disable prefer-default-export per feedback * :pencil2: Add forgotten divider * :shirt: Disable no-plusplus * :shirt: Disable class-methods-use-this * :pencil2: Alphabetize overrides * :shirt: Add one-var consecutive override * :rewind: Revert one-var consecutive override This reverts commit b9252cf935659ba6d76727ad484a1d3c00008fcc. * 🎨 👕 Lint and format workflow package (#2121) * :art: Format /workflow package * :shirt: Lint /workflow package * :art: Re-format /workflow package * :shirt: Re-lint /workflow package * :pencil2: Fix typo * :zap: Consolidate if-checks * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format node-dev package (#2122) * :art: Format /node-dev package * :zap: Exclude templates from ESLint config This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates. * :shirt: Lint /node-dev package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * 🎨 👕 Lint and format core package (#2123) * :art: Format /core package * :shirt: Lint /core package * :art: Re-format /core package * :shirt: Re-lint /core package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format cli package (#2124) * :art: Format /cli package * :shirt: Exclude migrations from linting * :shirt: Lint /cli package * :art: Re-format /cli package * :shirt: Re-lint /cli package * :shirt: Fix build * :fire: Remove prefer-default-export exceptions * :zap: Update exceptions in ActiveExecutions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 👕 fix lint issues * :wrench: use package specific linter, remove tslint command * :hammer: resolve build issue, sync dependencies * :wrench: change lint command Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
2021-08-29 11:58:11 -07:00
}),
:sparkles: Added logging to n8n (#1381) * Added logging to n8n This commit adds logging to n8n using the Winston library. For now, this commit only allows logging to console (default behavior) or file (need to pass in config via environment variables). Other logging methods can be further implemented using hooks. These were skipped for now as it would require adding more dependencies. Logging level is notice by default, meaning no additional messages would be displayed at the moment. Logging level can be set to info or debug as well to enrich the generated logs. The ILogger interface was added to the workflow project as it would make it available for all other projects but the implementation was done on the cli project. * Lint fixes and logging level naming. Also fixed the way we use the logger as it was not working previously * Improvements to logging framework Using appropriate single quotes Improving the way the logger is declared * Improved naming for Log Types * Removed logger global variable, replacing it by a proxy * Add logging to CLI commands * Remove unused GenericHelpers * Changed back some messages to console instead of logger and added npm shortcuts for worker and webhook * Fix typos * Adding basic file rotation to logs as suggested by @mutdmour * Fixed linting issues * Correcting comment to correctly reflect space usage * Added settings for log files rotation * Correcting config type from String to Number * Changed default file settings to number To reflect previous changes to the type * Changed the way log messages are added to be called statically. Also minor naming improvements * Applying latest corrections sent by @ivov * :zap: Some logging improvements * Saving logs to a folder inside n8n home instead of root * Fixed broken tests and linting * Changed some log messages to improve formatting * Adding quotes to names on log messages * Added execution and session IDs to logs. Also removed unnecessary line breaks * :zap: Added file caller to log messages (#1657) This is done using callsites library which already existed in the project as another library's dependency. So in fact it does not add any new dependency. * Adding logs to help debug Salesforce node * :zap: Add function name to logs and add more logs * :zap: Improve some error messages * :zap: Improve some more log messages * :zap: Rename logging env variables to match others Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-05-01 20:43:01 -07:00
);
}
if (output.includes('file')) {
const fileLogFormat = winston.format.combine(
winston.format.timestamp(),
winston.format.metadata(),
:art: Set up linting and formatting (#2120) * :arrow_up: Upgrade TS to 4.3.5 * :shirt: Add ESLint configs * :art: Add Prettier config * :package: Add deps and commands * :zap: Adjust global .editorconfig to new ruleset * :fire: Remove unneeded local .editorconfig * :package: Update deps in editor-ui * :hammer: Limit Prettier to only TS files * :zap: Add recommended VSCode extensions * :shirt: Fix build * :fire: Remove Vue setting from global config * :zap: Disable prefer-default-export per feedback * :pencil2: Add forgotten divider * :shirt: Disable no-plusplus * :shirt: Disable class-methods-use-this * :pencil2: Alphabetize overrides * :shirt: Add one-var consecutive override * :rewind: Revert one-var consecutive override This reverts commit b9252cf935659ba6d76727ad484a1d3c00008fcc. * 🎨 👕 Lint and format workflow package (#2121) * :art: Format /workflow package * :shirt: Lint /workflow package * :art: Re-format /workflow package * :shirt: Re-lint /workflow package * :pencil2: Fix typo * :zap: Consolidate if-checks * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format node-dev package (#2122) * :art: Format /node-dev package * :zap: Exclude templates from ESLint config This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates. * :shirt: Lint /node-dev package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * 🎨 👕 Lint and format core package (#2123) * :art: Format /core package * :shirt: Lint /core package * :art: Re-format /core package * :shirt: Re-lint /core package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format cli package (#2124) * :art: Format /cli package * :shirt: Exclude migrations from linting * :shirt: Lint /cli package * :art: Re-format /cli package * :shirt: Re-lint /cli package * :shirt: Fix build * :fire: Remove prefer-default-export exceptions * :zap: Update exceptions in ActiveExecutions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 👕 fix lint issues * :wrench: use package specific linter, remove tslint command * :hammer: resolve build issue, sync dependencies * :wrench: change lint command Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
2021-08-29 11:58:11 -07:00
winston.format.json(),
:sparkles: Added logging to n8n (#1381) * Added logging to n8n This commit adds logging to n8n using the Winston library. For now, this commit only allows logging to console (default behavior) or file (need to pass in config via environment variables). Other logging methods can be further implemented using hooks. These were skipped for now as it would require adding more dependencies. Logging level is notice by default, meaning no additional messages would be displayed at the moment. Logging level can be set to info or debug as well to enrich the generated logs. The ILogger interface was added to the workflow project as it would make it available for all other projects but the implementation was done on the cli project. * Lint fixes and logging level naming. Also fixed the way we use the logger as it was not working previously * Improvements to logging framework Using appropriate single quotes Improving the way the logger is declared * Improved naming for Log Types * Removed logger global variable, replacing it by a proxy * Add logging to CLI commands * Remove unused GenericHelpers * Changed back some messages to console instead of logger and added npm shortcuts for worker and webhook * Fix typos * Adding basic file rotation to logs as suggested by @mutdmour * Fixed linting issues * Correcting comment to correctly reflect space usage * Added settings for log files rotation * Correcting config type from String to Number * Changed default file settings to number To reflect previous changes to the type * Changed the way log messages are added to be called statically. Also minor naming improvements * Applying latest corrections sent by @ivov * :zap: Some logging improvements * Saving logs to a folder inside n8n home instead of root * Fixed broken tests and linting * Changed some log messages to improve formatting * Adding quotes to names on log messages * Added execution and session IDs to logs. Also removed unnecessary line breaks * :zap: Added file caller to log messages (#1657) This is done using callsites library which already existed in the project as another library's dependency. So in fact it does not add any new dependency. * Adding logs to help debug Salesforce node * :zap: Add function name to logs and add more logs * :zap: Improve some error messages * :zap: Improve some more log messages * :zap: Rename logging env variables to match others Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-05-01 20:43:01 -07:00
);
this.logger.add(
new winston.transports.File({
filename: config.get('logs.file.location'),
format: fileLogFormat,
:art: Set up linting and formatting (#2120) * :arrow_up: Upgrade TS to 4.3.5 * :shirt: Add ESLint configs * :art: Add Prettier config * :package: Add deps and commands * :zap: Adjust global .editorconfig to new ruleset * :fire: Remove unneeded local .editorconfig * :package: Update deps in editor-ui * :hammer: Limit Prettier to only TS files * :zap: Add recommended VSCode extensions * :shirt: Fix build * :fire: Remove Vue setting from global config * :zap: Disable prefer-default-export per feedback * :pencil2: Add forgotten divider * :shirt: Disable no-plusplus * :shirt: Disable class-methods-use-this * :pencil2: Alphabetize overrides * :shirt: Add one-var consecutive override * :rewind: Revert one-var consecutive override This reverts commit b9252cf935659ba6d76727ad484a1d3c00008fcc. * 🎨 👕 Lint and format workflow package (#2121) * :art: Format /workflow package * :shirt: Lint /workflow package * :art: Re-format /workflow package * :shirt: Re-lint /workflow package * :pencil2: Fix typo * :zap: Consolidate if-checks * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format node-dev package (#2122) * :art: Format /node-dev package * :zap: Exclude templates from ESLint config This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates. * :shirt: Lint /node-dev package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * 🎨 👕 Lint and format core package (#2123) * :art: Format /core package * :shirt: Lint /core package * :art: Re-format /core package * :shirt: Re-lint /core package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format cli package (#2124) * :art: Format /cli package * :shirt: Exclude migrations from linting * :shirt: Lint /cli package * :art: Re-format /cli package * :shirt: Re-lint /cli package * :shirt: Fix build * :fire: Remove prefer-default-export exceptions * :zap: Update exceptions in ActiveExecutions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 👕 fix lint issues * :wrench: use package specific linter, remove tslint command * :hammer: resolve build issue, sync dependencies * :wrench: change lint command Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
2021-08-29 11:58:11 -07:00
maxsize: (config.get('logs.file.fileSizeMax') as number) * 1048576, // config * 1mb
:sparkles: Added logging to n8n (#1381) * Added logging to n8n This commit adds logging to n8n using the Winston library. For now, this commit only allows logging to console (default behavior) or file (need to pass in config via environment variables). Other logging methods can be further implemented using hooks. These were skipped for now as it would require adding more dependencies. Logging level is notice by default, meaning no additional messages would be displayed at the moment. Logging level can be set to info or debug as well to enrich the generated logs. The ILogger interface was added to the workflow project as it would make it available for all other projects but the implementation was done on the cli project. * Lint fixes and logging level naming. Also fixed the way we use the logger as it was not working previously * Improvements to logging framework Using appropriate single quotes Improving the way the logger is declared * Improved naming for Log Types * Removed logger global variable, replacing it by a proxy * Add logging to CLI commands * Remove unused GenericHelpers * Changed back some messages to console instead of logger and added npm shortcuts for worker and webhook * Fix typos * Adding basic file rotation to logs as suggested by @mutdmour * Fixed linting issues * Correcting comment to correctly reflect space usage * Added settings for log files rotation * Correcting config type from String to Number * Changed default file settings to number To reflect previous changes to the type * Changed the way log messages are added to be called statically. Also minor naming improvements * Applying latest corrections sent by @ivov * :zap: Some logging improvements * Saving logs to a folder inside n8n home instead of root * Fixed broken tests and linting * Changed some log messages to improve formatting * Adding quotes to names on log messages * Added execution and session IDs to logs. Also removed unnecessary line breaks * :zap: Added file caller to log messages (#1657) This is done using callsites library which already existed in the project as another library's dependency. So in fact it does not add any new dependency. * Adding logs to help debug Salesforce node * :zap: Add function name to logs and add more logs * :zap: Improve some error messages * :zap: Improve some more log messages * :zap: Rename logging env variables to match others Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-05-01 20:43:01 -07:00
maxFiles: config.get('logs.file.fileCountMax'),
:art: Set up linting and formatting (#2120) * :arrow_up: Upgrade TS to 4.3.5 * :shirt: Add ESLint configs * :art: Add Prettier config * :package: Add deps and commands * :zap: Adjust global .editorconfig to new ruleset * :fire: Remove unneeded local .editorconfig * :package: Update deps in editor-ui * :hammer: Limit Prettier to only TS files * :zap: Add recommended VSCode extensions * :shirt: Fix build * :fire: Remove Vue setting from global config * :zap: Disable prefer-default-export per feedback * :pencil2: Add forgotten divider * :shirt: Disable no-plusplus * :shirt: Disable class-methods-use-this * :pencil2: Alphabetize overrides * :shirt: Add one-var consecutive override * :rewind: Revert one-var consecutive override This reverts commit b9252cf935659ba6d76727ad484a1d3c00008fcc. * 🎨 👕 Lint and format workflow package (#2121) * :art: Format /workflow package * :shirt: Lint /workflow package * :art: Re-format /workflow package * :shirt: Re-lint /workflow package * :pencil2: Fix typo * :zap: Consolidate if-checks * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format node-dev package (#2122) * :art: Format /node-dev package * :zap: Exclude templates from ESLint config This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates. * :shirt: Lint /node-dev package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * 🎨 👕 Lint and format core package (#2123) * :art: Format /core package * :shirt: Lint /core package * :art: Re-format /core package * :shirt: Re-lint /core package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format cli package (#2124) * :art: Format /cli package * :shirt: Exclude migrations from linting * :shirt: Lint /cli package * :art: Re-format /cli package * :shirt: Re-lint /cli package * :shirt: Fix build * :fire: Remove prefer-default-export exceptions * :zap: Update exceptions in ActiveExecutions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 👕 fix lint issues * :wrench: use package specific linter, remove tslint command * :hammer: resolve build issue, sync dependencies * :wrench: change lint command Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
2021-08-29 11:58:11 -07:00
}),
:sparkles: Added logging to n8n (#1381) * Added logging to n8n This commit adds logging to n8n using the Winston library. For now, this commit only allows logging to console (default behavior) or file (need to pass in config via environment variables). Other logging methods can be further implemented using hooks. These were skipped for now as it would require adding more dependencies. Logging level is notice by default, meaning no additional messages would be displayed at the moment. Logging level can be set to info or debug as well to enrich the generated logs. The ILogger interface was added to the workflow project as it would make it available for all other projects but the implementation was done on the cli project. * Lint fixes and logging level naming. Also fixed the way we use the logger as it was not working previously * Improvements to logging framework Using appropriate single quotes Improving the way the logger is declared * Improved naming for Log Types * Removed logger global variable, replacing it by a proxy * Add logging to CLI commands * Remove unused GenericHelpers * Changed back some messages to console instead of logger and added npm shortcuts for worker and webhook * Fix typos * Adding basic file rotation to logs as suggested by @mutdmour * Fixed linting issues * Correcting comment to correctly reflect space usage * Added settings for log files rotation * Correcting config type from String to Number * Changed default file settings to number To reflect previous changes to the type * Changed the way log messages are added to be called statically. Also minor naming improvements * Applying latest corrections sent by @ivov * :zap: Some logging improvements * Saving logs to a folder inside n8n home instead of root * Fixed broken tests and linting * Changed some log messages to improve formatting * Adding quotes to names on log messages * Added execution and session IDs to logs. Also removed unnecessary line breaks * :zap: Added file caller to log messages (#1657) This is done using callsites library which already existed in the project as another library's dependency. So in fact it does not add any new dependency. * Adding logs to help debug Salesforce node * :zap: Add function name to logs and add more logs * :zap: Improve some error messages * :zap: Improve some more log messages * :zap: Rename logging env variables to match others Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-05-01 20:43:01 -07:00
);
}
}
log(type: LogTypes, message: string, meta: object = {}) {
const callsite = callsites();
// We are using the third array element as the structure is as follows:
// [0]: this file
// [1]: Should be LoggerProxy
// [2]: Should point to the caller.
// Note: getting line number is useless because at this point
// We are in runtime, so it means we are looking at compiled js files
const logDetails = {} as IDataObject;
if (callsite[2] !== undefined) {
:art: Set up linting and formatting (#2120) * :arrow_up: Upgrade TS to 4.3.5 * :shirt: Add ESLint configs * :art: Add Prettier config * :package: Add deps and commands * :zap: Adjust global .editorconfig to new ruleset * :fire: Remove unneeded local .editorconfig * :package: Update deps in editor-ui * :hammer: Limit Prettier to only TS files * :zap: Add recommended VSCode extensions * :shirt: Fix build * :fire: Remove Vue setting from global config * :zap: Disable prefer-default-export per feedback * :pencil2: Add forgotten divider * :shirt: Disable no-plusplus * :shirt: Disable class-methods-use-this * :pencil2: Alphabetize overrides * :shirt: Add one-var consecutive override * :rewind: Revert one-var consecutive override This reverts commit b9252cf935659ba6d76727ad484a1d3c00008fcc. * 🎨 👕 Lint and format workflow package (#2121) * :art: Format /workflow package * :shirt: Lint /workflow package * :art: Re-format /workflow package * :shirt: Re-lint /workflow package * :pencil2: Fix typo * :zap: Consolidate if-checks * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format node-dev package (#2122) * :art: Format /node-dev package * :zap: Exclude templates from ESLint config This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates. * :shirt: Lint /node-dev package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * 🎨 👕 Lint and format core package (#2123) * :art: Format /core package * :shirt: Lint /core package * :art: Re-format /core package * :shirt: Re-lint /core package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format cli package (#2124) * :art: Format /cli package * :shirt: Exclude migrations from linting * :shirt: Lint /cli package * :art: Re-format /cli package * :shirt: Re-lint /cli package * :shirt: Fix build * :fire: Remove prefer-default-export exceptions * :zap: Update exceptions in ActiveExecutions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 👕 fix lint issues * :wrench: use package specific linter, remove tslint command * :hammer: resolve build issue, sync dependencies * :wrench: change lint command Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
2021-08-29 11:58:11 -07:00
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
:sparkles: Added logging to n8n (#1381) * Added logging to n8n This commit adds logging to n8n using the Winston library. For now, this commit only allows logging to console (default behavior) or file (need to pass in config via environment variables). Other logging methods can be further implemented using hooks. These were skipped for now as it would require adding more dependencies. Logging level is notice by default, meaning no additional messages would be displayed at the moment. Logging level can be set to info or debug as well to enrich the generated logs. The ILogger interface was added to the workflow project as it would make it available for all other projects but the implementation was done on the cli project. * Lint fixes and logging level naming. Also fixed the way we use the logger as it was not working previously * Improvements to logging framework Using appropriate single quotes Improving the way the logger is declared * Improved naming for Log Types * Removed logger global variable, replacing it by a proxy * Add logging to CLI commands * Remove unused GenericHelpers * Changed back some messages to console instead of logger and added npm shortcuts for worker and webhook * Fix typos * Adding basic file rotation to logs as suggested by @mutdmour * Fixed linting issues * Correcting comment to correctly reflect space usage * Added settings for log files rotation * Correcting config type from String to Number * Changed default file settings to number To reflect previous changes to the type * Changed the way log messages are added to be called statically. Also minor naming improvements * Applying latest corrections sent by @ivov * :zap: Some logging improvements * Saving logs to a folder inside n8n home instead of root * Fixed broken tests and linting * Changed some log messages to improve formatting * Adding quotes to names on log messages * Added execution and session IDs to logs. Also removed unnecessary line breaks * :zap: Added file caller to log messages (#1657) This is done using callsites library which already existed in the project as another library's dependency. So in fact it does not add any new dependency. * Adding logs to help debug Salesforce node * :zap: Add function name to logs and add more logs * :zap: Improve some error messages * :zap: Improve some more log messages * :zap: Rename logging env variables to match others Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-05-01 20:43:01 -07:00
logDetails.file = basename(callsite[2].getFileName() || '');
const functionName = callsite[2].getFunctionName();
if (functionName) {
logDetails.function = functionName;
}
}
:art: Set up linting and formatting (#2120) * :arrow_up: Upgrade TS to 4.3.5 * :shirt: Add ESLint configs * :art: Add Prettier config * :package: Add deps and commands * :zap: Adjust global .editorconfig to new ruleset * :fire: Remove unneeded local .editorconfig * :package: Update deps in editor-ui * :hammer: Limit Prettier to only TS files * :zap: Add recommended VSCode extensions * :shirt: Fix build * :fire: Remove Vue setting from global config * :zap: Disable prefer-default-export per feedback * :pencil2: Add forgotten divider * :shirt: Disable no-plusplus * :shirt: Disable class-methods-use-this * :pencil2: Alphabetize overrides * :shirt: Add one-var consecutive override * :rewind: Revert one-var consecutive override This reverts commit b9252cf935659ba6d76727ad484a1d3c00008fcc. * 🎨 👕 Lint and format workflow package (#2121) * :art: Format /workflow package * :shirt: Lint /workflow package * :art: Re-format /workflow package * :shirt: Re-lint /workflow package * :pencil2: Fix typo * :zap: Consolidate if-checks * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format node-dev package (#2122) * :art: Format /node-dev package * :zap: Exclude templates from ESLint config This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates. * :shirt: Lint /node-dev package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * 🎨 👕 Lint and format core package (#2123) * :art: Format /core package * :shirt: Lint /core package * :art: Re-format /core package * :shirt: Re-lint /core package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format cli package (#2124) * :art: Format /cli package * :shirt: Exclude migrations from linting * :shirt: Lint /cli package * :art: Re-format /cli package * :shirt: Re-lint /cli package * :shirt: Fix build * :fire: Remove prefer-default-export exceptions * :zap: Update exceptions in ActiveExecutions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 👕 fix lint issues * :wrench: use package specific linter, remove tslint command * :hammer: resolve build issue, sync dependencies * :wrench: change lint command Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
2021-08-29 11:58:11 -07:00
this.logger.log(type, message, { ...meta, ...logDetails });
:sparkles: Added logging to n8n (#1381) * Added logging to n8n This commit adds logging to n8n using the Winston library. For now, this commit only allows logging to console (default behavior) or file (need to pass in config via environment variables). Other logging methods can be further implemented using hooks. These were skipped for now as it would require adding more dependencies. Logging level is notice by default, meaning no additional messages would be displayed at the moment. Logging level can be set to info or debug as well to enrich the generated logs. The ILogger interface was added to the workflow project as it would make it available for all other projects but the implementation was done on the cli project. * Lint fixes and logging level naming. Also fixed the way we use the logger as it was not working previously * Improvements to logging framework Using appropriate single quotes Improving the way the logger is declared * Improved naming for Log Types * Removed logger global variable, replacing it by a proxy * Add logging to CLI commands * Remove unused GenericHelpers * Changed back some messages to console instead of logger and added npm shortcuts for worker and webhook * Fix typos * Adding basic file rotation to logs as suggested by @mutdmour * Fixed linting issues * Correcting comment to correctly reflect space usage * Added settings for log files rotation * Correcting config type from String to Number * Changed default file settings to number To reflect previous changes to the type * Changed the way log messages are added to be called statically. Also minor naming improvements * Applying latest corrections sent by @ivov * :zap: Some logging improvements * Saving logs to a folder inside n8n home instead of root * Fixed broken tests and linting * Changed some log messages to improve formatting * Adding quotes to names on log messages * Added execution and session IDs to logs. Also removed unnecessary line breaks * :zap: Added file caller to log messages (#1657) This is done using callsites library which already existed in the project as another library's dependency. So in fact it does not add any new dependency. * Adding logs to help debug Salesforce node * :zap: Add function name to logs and add more logs * :zap: Improve some error messages * :zap: Improve some more log messages * :zap: Rename logging env variables to match others Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-05-01 20:43:01 -07:00
}
// Convenience methods below
debug(message: string, meta: object = {}) {
this.log('debug', message, meta);
}
info(message: string, meta: object = {}) {
this.log('info', message, meta);
}
error(message: string, meta: object = {}) {
this.log('error', message, meta);
}
verbose(message: string, meta: object = {}) {
this.log('verbose', message, meta);
}
warn(message: string, meta: object = {}) {
this.log('warn', message, meta);
}
}
let activeLoggerInstance: Logger | undefined;
:art: Set up linting and formatting (#2120) * :arrow_up: Upgrade TS to 4.3.5 * :shirt: Add ESLint configs * :art: Add Prettier config * :package: Add deps and commands * :zap: Adjust global .editorconfig to new ruleset * :fire: Remove unneeded local .editorconfig * :package: Update deps in editor-ui * :hammer: Limit Prettier to only TS files * :zap: Add recommended VSCode extensions * :shirt: Fix build * :fire: Remove Vue setting from global config * :zap: Disable prefer-default-export per feedback * :pencil2: Add forgotten divider * :shirt: Disable no-plusplus * :shirt: Disable class-methods-use-this * :pencil2: Alphabetize overrides * :shirt: Add one-var consecutive override * :rewind: Revert one-var consecutive override This reverts commit b9252cf935659ba6d76727ad484a1d3c00008fcc. * 🎨 👕 Lint and format workflow package (#2121) * :art: Format /workflow package * :shirt: Lint /workflow package * :art: Re-format /workflow package * :shirt: Re-lint /workflow package * :pencil2: Fix typo * :zap: Consolidate if-checks * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format node-dev package (#2122) * :art: Format /node-dev package * :zap: Exclude templates from ESLint config This keeps the templates consistent with the codebase while preventing lint exceptions from being made part of the templates. * :shirt: Lint /node-dev package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * 🎨 👕 Lint and format core package (#2123) * :art: Format /core package * :shirt: Lint /core package * :art: Re-format /core package * :shirt: Re-lint /core package * :fire: Remove prefer-default-export exceptions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 🎨 👕 Lint and format cli package (#2124) * :art: Format /cli package * :shirt: Exclude migrations from linting * :shirt: Lint /cli package * :art: Re-format /cli package * :shirt: Re-lint /cli package * :shirt: Fix build * :fire: Remove prefer-default-export exceptions * :zap: Update exceptions in ActiveExecutions * :fire: Remove no-plusplus exceptions * :fire: Remove class-methods-use-this exceptions * 👕 fix lint issues * :wrench: use package specific linter, remove tslint command * :hammer: resolve build issue, sync dependencies * :wrench: change lint command Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
2021-08-29 11:58:11 -07:00
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
:sparkles: Added logging to n8n (#1381) * Added logging to n8n This commit adds logging to n8n using the Winston library. For now, this commit only allows logging to console (default behavior) or file (need to pass in config via environment variables). Other logging methods can be further implemented using hooks. These were skipped for now as it would require adding more dependencies. Logging level is notice by default, meaning no additional messages would be displayed at the moment. Logging level can be set to info or debug as well to enrich the generated logs. The ILogger interface was added to the workflow project as it would make it available for all other projects but the implementation was done on the cli project. * Lint fixes and logging level naming. Also fixed the way we use the logger as it was not working previously * Improvements to logging framework Using appropriate single quotes Improving the way the logger is declared * Improved naming for Log Types * Removed logger global variable, replacing it by a proxy * Add logging to CLI commands * Remove unused GenericHelpers * Changed back some messages to console instead of logger and added npm shortcuts for worker and webhook * Fix typos * Adding basic file rotation to logs as suggested by @mutdmour * Fixed linting issues * Correcting comment to correctly reflect space usage * Added settings for log files rotation * Correcting config type from String to Number * Changed default file settings to number To reflect previous changes to the type * Changed the way log messages are added to be called statically. Also minor naming improvements * Applying latest corrections sent by @ivov * :zap: Some logging improvements * Saving logs to a folder inside n8n home instead of root * Fixed broken tests and linting * Changed some log messages to improve formatting * Adding quotes to names on log messages * Added execution and session IDs to logs. Also removed unnecessary line breaks * :zap: Added file caller to log messages (#1657) This is done using callsites library which already existed in the project as another library's dependency. So in fact it does not add any new dependency. * Adding logs to help debug Salesforce node * :zap: Add function name to logs and add more logs * :zap: Improve some error messages * :zap: Improve some more log messages * :zap: Rename logging env variables to match others Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-05-01 20:43:01 -07:00
export function getLogger() {
if (activeLoggerInstance === undefined) {
activeLoggerInstance = new Logger();
}
return activeLoggerInstance;
}