Skip to content

Commit

Permalink
Merge pull request #681 from CleverCloud/fix/addon-logs
Browse files Browse the repository at this point in the history
fix(logs): show addon logs when addonId is provided
  • Loading branch information
miton18 authored Feb 14, 2024
2 parents efeeb48 + 6af9e22 commit 268d3c5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/commands/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ const LogV2 = require('../models/log.js');
const Log = require('../models/log-v4.js');
const Logger = require('../logger.js');
const { Deferred } = require('../models/utils.js');
const colors = require('colors/safe');

async function appLogs (params) {
const { alias, after: since, before: until, search, 'deployment-id': deploymentId } = params.options;
const { alias, addon: addonId, after: since, before: until, search, 'deployment-id': deploymentId } = params.options;

// ignore --search ""
const filter = (search !== '') ? search : null;

const { appId, ownerId } = await AppConfig.getAppDetails({ alias });

Logger.println('Waiting for application logs…');

// TODO: drop when addons are migrated to the v4 API
if (params.addon) {
const { addon: addonId } = params.options;
const appAddonId = addonId || await AppConfig.getAppDetails({ alias }).then(({ appId }) => appId);
return LogV2.displayLogs({ appAddonId, since, until, filter, deploymentId });
if (addonId) {
Logger.println(colors.blue('Waiting for addon logs…'));
return LogV2.displayLogs({ appAddonId: addonId, since, until, filter, deploymentId });
}

Logger.println(colors.blue('Waiting for application logs…'));

const deferred = new Deferred();
await Log.displayLogs({ ownerId, appId, since, until, filter, deploymentId, deferred });
return deferred.promise;
Expand Down

0 comments on commit 268d3c5

Please sign in to comment.