implement logging properly
This commit is contained in:
+10
-4
@@ -5,17 +5,20 @@ import { serveHttp } from "../http_server.js";
|
||||
import { opt } from "../options.js";
|
||||
import { pair } from "../pair.js";
|
||||
|
||||
import { buildLogger } from "../logger.js";
|
||||
|
||||
yargs(hideBin(process.argv))
|
||||
.command(
|
||||
"http_server",
|
||||
"start http server",
|
||||
(yargs) => {
|
||||
return yargs
|
||||
.option("debug", { describe: "Log debug messages", default: false })
|
||||
.option("ansi", { default: false })
|
||||
.option("slow_startup", { default: false })
|
||||
.option("audio", { describe: "Also stream audio from camera", default: true })
|
||||
.boolean(["debug", "ansi", "audio", "slow_startup"])
|
||||
.option("color", { describe: "Use color in logs", default: undefined })
|
||||
.boolean(["ansi", "audio", "slow_startup", "color"])
|
||||
.option("log_level", { describe: "Set log level", default: "info" })
|
||||
.option("discovery_ip", { describe: "Camera discovery IP address", default: "192.168.1.255" })
|
||||
.option("attempt_to_fix_packet_loss", { default: false })
|
||||
.option("port", { describe: "HTTP Port to listen on", default: 5000 })
|
||||
@@ -24,6 +27,7 @@ yargs(hideBin(process.argv))
|
||||
},
|
||||
(argv) => {
|
||||
const opts: opt = argv as opt;
|
||||
buildLogger(argv.log_level, argv.color);
|
||||
serveHttp(opts, argv.port, argv.audio || false);
|
||||
},
|
||||
)
|
||||
@@ -32,10 +36,11 @@ yargs(hideBin(process.argv))
|
||||
"configure a camera",
|
||||
(yargs) => {
|
||||
return yargs
|
||||
.option("debug", { describe: "Log debug messages", default: false })
|
||||
.option("ansi", { default: false })
|
||||
.option("slow_startup", { default: false })
|
||||
.boolean(["debug", "ansi", "slow_startup"])
|
||||
.option("color", { describe: "Use color in logs", default: undefined })
|
||||
.boolean(["ansi", "slow_startup", "color"])
|
||||
.option("log_level", { describe: "Set log level", default: "info" })
|
||||
.option("discovery_ip", { describe: "Camera discovery IP address", default: "192.168.1.255" })
|
||||
.option("attempt_to_fix_packet_loss", { default: false })
|
||||
.option("ssid", { describe: "Wifi network for the camera to connect to" })
|
||||
@@ -45,6 +50,7 @@ yargs(hideBin(process.argv))
|
||||
},
|
||||
(argv) => {
|
||||
const opts: opt = argv as unknown as opt;
|
||||
buildLogger(argv.log_level, argv.color);
|
||||
pair({ opts, ssid: argv.ssid, password: argv.password });
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user