Skip to content

Commit

Permalink
Merge pull request inventid#73 from inventid/improved-strings
Browse files Browse the repository at this point in the history
Make logging more consistent
  • Loading branch information
rogierslag authored Jul 5, 2016
2 parents 19f5782 + 8afaebf commit f5b308f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/imageResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ const redirectImageToWithinBounds = (params, response) => {
};

const redirectToCachedEntity = (cacheUrl, params, response) => {
log('info', `cache hit for ${params.name}.${params.type} (${params.width}x${params.height}px, fit: ${params.fit}, blur: ${Boolean(params.blur)})`); //eslint-disable-line max-len
response.status(307).set({
'Location': cacheUrl,
'Cache-Control': 'public',
Expand Down Expand Up @@ -101,17 +100,17 @@ export default {
response.status(200).end();
return;
}
log('info', `Requesting file ${params.name} in ${params.type} format in a ${params.width}x${params.height}px resolution`); //eslint-disable-line max-len
log('info', `Request for ${params.name}.${params.type} (${params.width}x${params.height}px, fit: ${params.fit}, blur: ${Boolean(params.blur)})`); //eslint-disable-line max-len

const cacheValue = await cache.getFromCache(params);
if (cacheValue) {
log('info', `Cache hit for ${params.name} in ${params.type} format in a ${params.width}x${params.height}px resolution`); //eslint-disable-line max-len
log('info', `Cache hit for ${params.name}.${params.type} (${params.width}x${params.height}px, fit: ${params.fit}, blur: ${Boolean(params.blur)})`); //eslint-disable-line max-len
redirectToCachedEntity(cacheValue, params, response);
return;
}

// Image is present but not in the correct setting
log('info', `Cache miss for ${params.name} in ${params.type} format in a ${params.width}x${params.height}px resolution`); //eslint-disable-line max-len
log('info', `Cache mis for ${params.name}.${params.type} (${params.width}x${params.height}px, fit: ${params.fit}, blur: ${Boolean(params.blur)})`); //eslint-disable-line max-len
sendFoundHeaders(params, response);

const browserImage = await image.magic(imagePath(params.name), params, response);
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ server.use((req, res, next) => {
server.get('/_health', (req, res) => {
if (db) {
res.status(200).end('OK');
log('info', 'healthcheck OK');
log('info', 'Healthcheck OK');
} else {
res.status(500).end('No database connection');
log('error', 'healthcheck FAILED');
log('error', 'Healthcheck FAILED');
}
});
server.get('/robots.txt', (req, res) => {
const content = (config.has('allow_indexing') && config.get('allow_indexing')) ?
"User-agent: *\nAllow: /" : "User-agent: *\nDisallow: /";
res.status(200).end(content);
log('info', 'robots.txt served');
log('info', 'Robots.txt served');
});

// The actual endpoints for fetching
Expand Down Expand Up @@ -131,7 +131,7 @@ server.post('/(:name)', uploadImage);

pg.connect(connectionString, (err, client) => {
if (err) {
log('error', `error fetching client from pool: ${err}`);
log('error', `Error fetching client from pool: ${err}`);
} else {
db = client;
migrateAndStart(db, './migrations', () => {
Expand Down

0 comments on commit f5b308f

Please sign in to comment.