-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f4c4bd
commit 6430485
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { command, flag, subcommands } from "cmd-ts"; | ||
import { createClient, createClientArgs } from "../createClient"; | ||
import { createLogger, logLevelArgs } from "../logLevel"; | ||
|
||
const stream = command({ | ||
name: "stream", | ||
description: "Stream logs from LM Studio", | ||
args: { | ||
json: flag({ | ||
long: "json", | ||
description: "Outputs in JSON format, separated by newline", | ||
}), | ||
...logLevelArgs, | ||
...createClientArgs, | ||
}, | ||
async handler(args) { | ||
const logger = createLogger(args); | ||
const client = await createClient(logger, args); | ||
const { json } = args; | ||
|
||
logger.info("Streaming logs from LM Studio\n"); | ||
|
||
client.diagnostics.unstable_streamLogs(log => { | ||
if (json) { | ||
console.log(JSON.stringify(log)); | ||
} else { | ||
const better = { | ||
...log, | ||
timestamp: new Date(log.timestamp).toISOString(), | ||
}; | ||
console.log(better); | ||
} | ||
}); | ||
}, | ||
}); | ||
|
||
export const log = subcommands({ | ||
name: "log", | ||
description: | ||
"Log operations. Currently only supports streaming logs from LM Studio via `lms log stream`", | ||
cmds: { | ||
stream, | ||
}, | ||
}); |