Skip to content

Commit

Permalink
add debug log for MF adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Xziy committed Feb 26, 2024
1 parent 51cb099 commit ed7eec1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 deletions adapters/mediafile/default/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class LocalMediaFileAdapter extends MediaFileAdapter_1.default {
// Check if file exists
if (!fs.existsSync(fullPathDl)) {
const response = await axios_1.default.get(loadMediaFilesProcess.url, { responseType: 'stream' });
sails.log.silly(`MF local > download image: ${fullPathDl}, status: ${response.status}`);
sails.log.debug(`MF local > download image: ${fullPathDl}, status: ${response.status}`);
fs.mkdirSync(prefix, { recursive: true });
const writer = fs.createWriteStream(fullPathDl);
response.data.pipe(writer);
Expand Down Expand Up @@ -146,7 +146,7 @@ class LocalMediaFileAdapter extends MediaFileAdapter_1.default {
const prefix = this.getPrefix(loadMediaFilesProcess.type);
switch (loadMediaFilesProcess.type) {
case "image":
sails.log.silly(`MF local > process image: ${loadMediaFilesProcess.name.origin}`);
sails.log.debug(`MF local > process image: ${loadMediaFilesProcess.name.origin}`);
for (let size in loadMediaFilesProcess.config.resize) {
const dstPath = path.join(prefix, loadMediaFilesProcess.name[size]);
if (!fs.existsSync(dstPath)) {
Expand All @@ -163,10 +163,10 @@ class LocalMediaFileAdapter extends MediaFileAdapter_1.default {
size: mediafileItem,
customArgs: ["-background", loadMediaFilesProcess.config.background || "white", "-flatten"],
});
sails.log.silly(`MF local > process finished: ${loadMediaFilesProcess.name[size]}`);
sails.log.debug(`MF local > process finished: ${loadMediaFilesProcess.name[size]}`);
}
else {
sails.log.silly(`MF local > process skip existing processed file: ${loadMediaFilesProcess.name[size]}`);
sails.log.debug(`MF local > process skip existing processed file: ${loadMediaFilesProcess.name[size]}`);
}
}
break;
Expand Down Expand Up @@ -199,7 +199,7 @@ function resizeMediaFile({ srcPath, dstPath, size, customArgs }) {
if (err) {
return reject(new Error(err));
}
// Определяем, какая сторона меньше
// Determine which side is smaller
let resizeWidth, resizeHeight;
if (dimensions.width > dimensions.height) {
resizeWidth = Math.round(size * (dimensions.width / dimensions.height));
Expand Down
10 changes: 5 additions & 5 deletions adapters/mediafile/default/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export default class LocalMediaFileAdapter extends MediaFileAdapter {
// Check if file exists
if (!fs.existsSync(fullPathDl)) {
const response = await axios.get(loadMediaFilesProcess.url, { responseType: 'stream' });
sails.log.silly(`MF local > download image: ${fullPathDl}, status: ${response.status}`);
sails.log.debug(`MF local > download image: ${fullPathDl}, status: ${response.status}`);

fs.mkdirSync(prefix, { recursive: true });

Expand Down Expand Up @@ -170,7 +170,7 @@ export default class LocalMediaFileAdapter extends MediaFileAdapter {
const prefix = this.getPrefix(loadMediaFilesProcess.type);
switch (loadMediaFilesProcess.type) {
case "image":
sails.log.silly(`MF local > process image: ${loadMediaFilesProcess.name.origin}`)
sails.log.debug(`MF local > process image: ${loadMediaFilesProcess.name.origin}`)
for (let size in loadMediaFilesProcess.config.resize) {
const dstPath = path.join(prefix,loadMediaFilesProcess.name[size])
if (!fs.existsSync(dstPath)) {
Expand All @@ -187,9 +187,9 @@ export default class LocalMediaFileAdapter extends MediaFileAdapter {
size: mediafileItem,
customArgs: ["-background", loadMediaFilesProcess.config.background || "white", "-flatten"],
});
sails.log.silly(`MF local > process finished: ${loadMediaFilesProcess.name[size]}`)
sails.log.debug(`MF local > process finished: ${loadMediaFilesProcess.name[size]}`)
} else {
sails.log.silly(`MF local > process skip existing processed file: ${loadMediaFilesProcess.name[size]}`)
sails.log.debug(`MF local > process skip existing processed file: ${loadMediaFilesProcess.name[size]}`)
}
}
break;
Expand Down Expand Up @@ -230,7 +230,7 @@ function resizeMediaFile({ srcPath, dstPath, size, customArgs }: ResizeMediaFile
return reject(new Error(err));
}

// Определяем, какая сторона меньше
// Determine which side is smaller
let resizeWidth, resizeHeight;
if (dimensions.width > dimensions.height) {
resizeWidth = Math.round(size * (dimensions.width / dimensions.height));
Expand Down
1 change: 1 addition & 0 deletions test/integration/promotionCode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ describe("Promotion code integration test", function () {
console.log(result, 2);
(0, chai_1.expect)(result.discountTotal).to.equal(0);
(0, chai_1.expect)(result.total).to.equal(111.3);
(0, chai_1.expect)(result.state).to.equal("CART");
// NOT VALID PROMOCODE
await Order.applyPromotionCode({ id: order.id }, "WINTER2024NHATRANG");
result = await Order.findOne({ id: order.id });
Expand Down

0 comments on commit ed7eec1

Please sign in to comment.