Skip to content

Commit d3914aa

Browse files
authored
Merge pull request #153 from eexit/fix-debugger
Fix debugger initialization and add more debug insight
2 parents fd20cd0 + 6a5548b commit d3914aa

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

index.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const StorageBase = require('ghost-storage-base'),
77
path = require('path'),
88
got = require('got'),
99
plugin = require(path.join(__dirname, '/plugins')),
10-
debug = require('@tryghost/debug'),
10+
debug = require('@tryghost/debug')('adapter'),
1111
common = (() => {
1212
// Tries to include GhostError helper
1313
try {
@@ -40,9 +40,9 @@ class CloudinaryAdapter extends StorageBase {
4040
fetch: fetchOptions
4141
};
4242

43-
debug('useDatedFolder:', this.useDatedFolder);
44-
debug('uploaderOptions:', this.uploaderOptions);
45-
debug('rjsOptions:', this.rjsOptions);
43+
debug('constructor:useDatedFolder:', this.useDatedFolder);
44+
debug('constructor:uploaderOptions:', this.uploaderOptions);
45+
debug('constructor:rjsOptions:', this.rjsOptions);
4646

4747
cloudinary.config(auth);
4848
}
@@ -51,6 +51,8 @@ class CloudinaryAdapter extends StorageBase {
5151
* @override
5252
*/
5353
exists(filename) {
54+
debug('exists:filename', filename);
55+
5456
const pubId = this.toCloudinaryId(filename);
5557

5658
return new Promise((resolve) => cloudinary.uploader.explicit(pubId, { type: 'upload' }, (err) => {
@@ -107,12 +109,16 @@ class CloudinaryAdapter extends StorageBase {
107109

108110
return new Promise((resolve, reject) => cloudinary.uploader.upload(imagePath, options.upload, (err, res) => {
109111
if (err) {
112+
debug('uploader:error', err);
113+
110114
return reject(new common.errors.GhostError({
111115
err: err,
112116
message: `Could not upload image ${imagePath}`
113117
}));
114118
}
115119
if (url) {
120+
debug('uploader:url', url);
121+
116122
return resolve(cloudinary.url(res.public_id.concat('.', res.format), options.fetch));
117123
}
118124
return resolve();
@@ -132,10 +138,14 @@ class CloudinaryAdapter extends StorageBase {
132138
* @override
133139
*/
134140
delete(filename) {
141+
debug('delete:filename', filename);
142+
135143
const pubId = this.toCloudinaryId(filename);
136144

137145
return new Promise((resolve, reject) => cloudinary.uploader.destroy(pubId, (err, res) => {
138146
if (err) {
147+
debug('delete:error', err);
148+
139149
return reject(new common.errors.GhostError({
140150
err: err,
141151
message: `Could not delete image ${filename}`
@@ -150,13 +160,19 @@ class CloudinaryAdapter extends StorageBase {
150160
*/
151161
read(options) {
152162
const opts = options || {};
163+
164+
debug('read:opts', opts);
165+
153166
return new Promise(async (resolve, reject) => {
154167
try {
155168
return resolve(await got(opts.path, {
156169
responseType: 'buffer',
157170
resolveBodyOnly: true
158171
}));
159172
} catch (err) {
173+
174+
debug('read:error', err);
175+
160176
return reject(new common.errors.GhostError({
161177
err: err,
162178
message: `Could not read image ${opts.path}`

plugins/retinajs.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ require('bluebird');
44

55
const _ = require('lodash'),
66
sizeOf = require('image-size'),
7+
debug = require('@tryghost/debug')('plugins:retinajs'),
78
maxSupportedDpr = 5;
89

910
class RetinaJS {
@@ -15,6 +16,8 @@ class RetinaJS {
1516
this.rjsOptions.baseWidth = parseInt(this.rjsOptions.baseWidth, 10);
1617
this.rjsOptions.fireForget = this.rjsOptions.fireForget || false;
1718

19+
debug('constructor:rjsOptions', this.rjsOptions);
20+
1821
if (typeof this.uploader !== 'function') {
1922
throw new TypeError('RetinaJS: uploader must be callable');
2023
}
@@ -44,6 +47,11 @@ class RetinaJS {
4447
const that = this,
4548
[head, ...tail] = this.generateDprConfigs(this.resolveMaxDpr(image.path));
4649

50+
debug('retinize:configs', {
51+
head: head,
52+
tail: tail
53+
});
54+
4755
// Image is not retinizable: creates DPR 1.0 variant only
4856
if (tail.length === 0) {
4957
return that.uploader(image.path, head, true);

0 commit comments

Comments
 (0)