Skip to content

Commit

Permalink
log.debug
Browse files Browse the repository at this point in the history
  • Loading branch information
philrz committed Jan 19, 2024
1 parent a0bcc84 commit 03adf2e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
17 changes: 9 additions & 8 deletions apps/zui/src/js/lib/open.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict"

import env from "src/app/core/env"
import * as log from "src/core/log"

const isWsl = require("is-wsl")

Expand Down Expand Up @@ -29,7 +30,7 @@ type ChildProcessOpts = {
}

export default async function open(target: string, options?: Opts) {
console.log("I have entered open()")
log.debug("I have entered open()")

if (typeof target !== "string") {
throw new TypeError("Expected a `target`")
Expand Down Expand Up @@ -88,26 +89,26 @@ export default async function open(target: string, options?: Opts) {
cliArguments.push(...appArguments)
}
} else {
console.log("I am in open() and I am neither macOS nor Windows")
log.debug("I am in open() and I am neither macOS nor Windows")
if (options.app) {
command = options.app
} else {
console.log(
log.debug(
"I am in open() and I am deciding whether to use system xdg-open"
)
const useSystemXdgOpen =
process.versions.electron || process.platform === "android"
command = useSystemXdgOpen ? "xdg-open" : path.join(__dirname, "xdg-open")
}

console.log("I am in open() and here is command: " + command)
log.debug("I am in open() and here is command: " + command)

if (appArguments.length > 0) {
cliArguments.push(...appArguments)
}

if (!options.wait) {
console.log(
log.debug(
"I am in open() and I am setting the process options to avoid blocking"
)
// `xdg-open` will block the process unless stdio is ignored
Expand All @@ -123,7 +124,7 @@ export default async function open(target: string, options?: Opts) {
cliArguments.push("--args", ...appArguments)
}

console.log("I am in open() and I am about to spawn the childProcess")
log.debug("I am in open() and I am about to spawn the childProcess")
const subprocess = childProcess.spawn(
command,
cliArguments,
Expand All @@ -145,9 +146,9 @@ export default async function open(target: string, options?: Opts) {
})
}

console.log("I am in open() and about to unref the subprocess")
log.debug("I am in open() and about to unref the subprocess")
subprocess.unref()

console.log("I am in open() and about to return the subprocess")
log.debug("I am in open() and about to return the subprocess")
return subprocess
}
3 changes: 2 additions & 1 deletion apps/zui/src/plugins/brimcap/packets/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import os from "os"
import {window, env, commands} from "src/zui"
import {queryForConnLog} from "./query-conn-log"
import {DOWNLOAD} from "./types"
import * as log from "src/core/log"

function getSearchArgsFromConn(conn: zed.Record) {
const dur = conn.try("duration") as zed.Duration
Expand Down Expand Up @@ -39,7 +40,7 @@ export async function downloadPackets(root: string, pool: string, uid: string) {
window.showErrorMessage(msg)
} else {
// Commenting this out to see if the "blocking" in openExternal might be the problem
console.log('I am about to call openExternal()')
log.debug("I am about to call openExternal()")
env.openExternal(dest)
window.showSuccessMessage("Packets extracted. Opening...")
}
Expand Down

0 comments on commit 03adf2e

Please sign in to comment.