Skip to content

Commit

Permalink
Merge pull request #2054 from Accenture/task/2027-move-deltapackage-l…
Browse files Browse the repository at this point in the history
…og-from-docs-folder-into-logs-folder

Task/2027 move deltapackage log from docs folder into logs folder
  • Loading branch information
JoernBerkefeld authored Feb 6, 2025
2 parents d3a0eff + 14b5147 commit 550aa7f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
1 change: 0 additions & 1 deletion boilerplate/gitignore-template
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
node_modules/
/deploy/
/docs/badKeys/
/docs/deltaPackage/
/logs/
**/QueryStudioResults at*
.mcdev-auth.json
Expand Down
7 changes: 6 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,12 @@ class Mcdev {
);

// reset temporary template folder
await File.remove(properties.directories.template);
try {
await File.remove(properties.directories.template);
} catch {
// sometimes the first attempt is not successful for some operating system reason. Trying again mostly solves this
await File.remove(properties.directories.template);
}
properties.directories.template = templateDirBackup;

return response;
Expand Down
9 changes: 3 additions & 6 deletions lib/util/devops.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,8 @@ const DevOps = {
return [];
}
// Write into delta.json to serve as documentation
const directoryDeltaPkg = File.normalizePath([
properties.directories.docs,
'deltaPackage/',
]);
await File.writeJSONToFile(directoryDeltaPkg, 'delta_package', delta);
const directoryDeltaPkg = 'logs/';
await File.writeJSONToFile(directoryDeltaPkg, Util.logFileName + '-delta_package', delta);
this.document(directoryDeltaPkg, delta);
Util.logger.info(
`- ✔️ Identified changes: Add/Update=${gitActionsCounter['add/update']}, Move=${gitActionsCounter['move']}, Delete=${gitActionsCounter['delete']}`
Expand Down Expand Up @@ -556,7 +553,7 @@ const DevOps = {
}
try {
// write to disk (asynchronously)
File.writeToFile(directory, 'delta_package', 'md', output);
File.writeToFile(directory, Util.logFileName + '-delta_package', 'md', output);
} catch (ex) {
Util.logger.error(`DevOps.document():: error | ` + ex.message);
}
Expand Down
8 changes: 5 additions & 3 deletions lib/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ export const Util = {

return typeChoices;
},
/** @type {string} last used timestamp to create log filename with */
logFileName: null,

/**
* wrapper around our standard winston logging to console and logfile
Expand All @@ -364,7 +366,7 @@ export const Util = {
) {
Util.OPTIONS.noLogColors = true;
}
const logFileName = new Date().toISOString().split(':').join('.');
Util.logFileName = new Date().toISOString().split(':').join('.');
const transports = {
console: new winston.transports.Console({
// Write logs to Console
Expand All @@ -384,7 +386,7 @@ export const Util = {
if (!noLogFile) {
transports.file = new winston.transports.File({
// Write logs to logfile
filename: 'logs/' + logFileName + '.log',
filename: 'logs/' + Util.logFileName + '.log',
level: 'debug', // log everything
format: winston.format.combine(
winston.format.uncolorize(),
Expand All @@ -399,7 +401,7 @@ export const Util = {
// used by CI/CD solutions like Copado to quickly show the error message to admins/users
transports.fileError = new winston.transports.File({
// Write logs to additional error-logfile for better visibility of errors
filename: 'logs/' + logFileName + '-errors.log',
filename: 'logs/' + Util.logFileName + '-errors.log',
level: 'error', // only log errors
lazy: true, // if true, log files will be created on demand, not at the initialization time.
format: winston.format.combine(
Expand Down

0 comments on commit 550aa7f

Please sign in to comment.