@forge/cli-shared

9.4.0-next.109.4.0-next.11
out/app-logs/view-logs.js
~out/app-logs/view-logs.jsModified
+14−4
Index: package/out/app-logs/view-logs.js
===================================================================
--- package/out/app-logs/view-logs.js
+++ package/out/app-logs/view-logs.js
@@ -20,9 +20,9 @@
         this.globalEdgeClient = globalEdgeClient;
         this.logsClient = logsClient;
         this.statsigService = statsigService;
     }
-    async getAll({ environmentKey, limit, context, startTime = null, grouped = false, containers = false }) {
+    async getAll({ environmentKey, limit, context, containerKey, containerInstance, serviceKey, functionKey, startTime = null, grouped = false }) {
         const { id: appId } = await this.getAppConfig();
         const [environmentId, cloudId] = await Promise.all([
             this.appEnvironmentClient.getAppEnvironmentId(appId, environmentKey),
             context ? this.globalEdgeClient.getCloudId(context.site) : undefined
@@ -35,18 +35,24 @@
             startTime,
             contextAri: contextAri ? [contextAri] : undefined,
             grouped
         };
-        if (containers) {
+        if (containerKey || containerInstance || serviceKey) {
             details.runtime = Runtime.CONTAINER.toLowerCase();
         }
         const isV2ApiEnabled = await this.statsigService.isLogsV2ApiEnabled();
         if (isV2ApiEnabled) {
-            return this.getLogs(details);
+            const containerDetails = {
+                containerKey,
+                containerInstance,
+                serviceKey,
+                functionKey
+            };
+            return this.getLogs(details, containerDetails);
         }
         return this.logsClient.viewAppLogs(details);
     }
-    async getLogs(details) {
+    async getLogs(details, containerDetails) {
         const latestStart = new Date().toISOString();
         let earliestStart = new Date();
         if (details.startTime) {
             earliestStart = new Date(details.startTime);
@@ -59,8 +65,12 @@
             latestStart
         };
         return this.logsClient.viewAppLogsV2({
             ...details,
+            containers: containerDetails.containerKey ? [containerDetails.containerKey] : [],
+            instances: containerDetails.containerInstance ? [containerDetails.containerInstance] : [],
+            services: containerDetails.serviceKey ? [containerDetails.serviceKey] : [],
+            functionKeys: containerDetails.functionKey ? [containerDetails.functionKey] : [],
             offset: 0,
             dateSearchInput,
             queryStartTime: earliestStart.toISOString(),
             maxLimit: details.limit