logs: use %o to format error

otherwise, they are printed as multi-line and this messes up tail+date formatting
This commit is contained in:
Girish Ramakrishnan
2023-04-16 10:49:59 +02:00
parent e6f870b220
commit c4f4f3e914
29 changed files with 70 additions and 73 deletions
+7 -7
View File
@@ -440,7 +440,7 @@ async function getServiceLogs(id, options) {
throw new BoxError(BoxError.NOT_FOUND, 'Service not found');
}
debug(`Getting logs for ${name}`);
debug(`getServiceLogs: getting logs for ${name}`);
let cp;
@@ -535,7 +535,7 @@ async function startAppServices(app) {
const [error] = await safe(APP_SERVICES[addon].start(instance)); // assume addons name is service name
// error ignored because we don't want "start app" to error. use can fix it from Services
if (error) debug(`startAppServices: ${addon}:${instance}`, error);
if (error) debug(`startAppServices: ${addon}:${instance}. %o`, error);
}
}
@@ -549,7 +549,7 @@ async function stopAppServices(app) {
const [error] = await safe(APP_SERVICES[addon].stop(instance)); // assume addons name is service name
// error ignored because we don't want "start app" to error. use can fix it from Services
if (error) debug(`stopAppServices: ${addon}:${instance}`, error);
if (error) debug(`stopAppServices: ${addon}:${instance}. %o`, error);
}
}
@@ -682,7 +682,7 @@ async function importDatabase(addon) {
const [error] = await safe(importAppDatabase(app, addon));
if (!error) continue;
debug(`importDatabase: Error importing ${addon} of app ${app.id}. Marking as errored`, error);
debug(`importDatabase: Error importing ${addon} of app ${app.id}. Marking as errored. %o`, error);
// FIXME: there is no way to 'repair' if we are here. we need to make a separate apptask that re-imports db
// not clear, if repair workflow should be part of addon or per-app
await safe(apps.update(app.id, { installationState: apps.ISTATE_ERROR, error: { message: error.message } }));
@@ -711,7 +711,7 @@ async function exportDatabase(addon) {
const [error] = await safe(ADDONS[addon].backup(app, app.manifest.addons[addon]));
if (error) {
debug(`exportDatabase: Error exporting ${addon} of app ${app.id}.`, error);
debug(`exportDatabase: Error exporting ${addon} of app ${app.id}. %o`, error);
// for errored apps, we can ignore if export had an error
if (app.installationState === apps.ISTATE_ERROR) continue;
throw error;
@@ -1790,7 +1790,7 @@ async function teardownRedis(app, options) {
if (error) throw new BoxError(BoxError.FS_ERROR, `Error removing redis data: ${error.message}`);
safe.fs.rmSync(path.join(paths.LOG_DIR, `redis-${app.id}`), { recursive: true, force: true });
if (safe.error) debug('cannot cleanup logs:', safe.error);
if (safe.error) debug('teardownRedis: cannot cleanup logs: %o', safe.error);
await addonConfigs.unset(app.id, 'redis');
}
@@ -1868,7 +1868,7 @@ async function statusUnbound() {
const [digError, digResult] = await safe(dig.resolve('ipv4.api.cloudron.io', 'A', { server: '127.0.0.1', timeout: 10000 }));
if (!digError && Array.isArray(digResult) && digResult.length !== 0) return { status: exports.SERVICE_STATUS_ACTIVE };
debug('statusUnbound: unbound is up, but failed to resolve ipv4.api.cloudron.io', digError, digResult);
debug('statusUnbound: unbound is up, but failed to resolve ipv4.api.cloudron.io . %o %j', digError, digResult);
return { status: exports.SERVICE_STATUS_STARTING };
}