Skip to content

Commit

Permalink
Use rust side logging (#36)
Browse files Browse the repository at this point in the history
- [x] Save logs to expected places on all platforms
- [x] Forward logs to VSCode Output Pane
  • Loading branch information
esarver committed Jul 26, 2024
1 parent 39517c3 commit 8dc7a1b
Show file tree
Hide file tree
Showing 10 changed files with 523 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ settings:
rules:
# eslint
indent:
- error
- "error"
- 4
- SwitchCase: 1
linebreak-style:
- error
- unix
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
Security -- in case of vulnerabilities.
-->

## [0.17.0]

### Added
- Add logging for terminal and discover

## [0.16.4]

### Changed
Expand Down Expand Up @@ -123,7 +128,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
- Feature to retrieve TSP-Link network details

<!-- Version Comparison Links -->
[Unreleased]: https://github.com/tektronix/tsp-toolkit/compare/v0.16.4...HEAD
[Unreleased]: https://github.com/tektronix/tsp-toolkit/compare/v0.17.0...HEAD
[0.17.0]: https://github.com/tektronix/tsp-toolkit/releases/tag/v0.16.4
[0.16.4]: https://github.com/tektronix/tsp-toolkit/releases/tag/v0.16.4
[0.16.1]: https://github.com/tektronix/tsp-toolkit/releases/tag/v0.16.1
[0.15.3]: https://github.com/tektronix/tsp-toolkit/releases/tag/v0.15.3
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publisher": "Tektronix",
"displayName": "[Beta] Keithley TSP Toolkit",
"description": "VSCode extension for Keithley Instruments' Test Script Processor",
"version": "0.16.4",
"version": "0.17.0",
"icon": "./resources/TSP_Toolkit_128x128.png",
"galleryBanner": {
"color": "#EEEEEE",
Expand Down Expand Up @@ -325,7 +325,7 @@
},
"dependencies": {
"@tektronix/keithley_instrument_libraries": "0.16.0",
"@tektronix/kic-cli": "0.16.2-0",
"@tektronix/kic-cli": "0.17.0-1",
"@tektronix/web-help-documents": "0.15.3",
"@types/cheerio": "^0.22.35",
"cheerio": "^1.0.0-rc.12",
Expand Down
17 changes: 16 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
processWorkspaceFolders,
RELATIVE_TSP_CONFIG_FILE_PATH,
} from "./workspaceManager"
import { LOG_DIR } from "./utility"
import { LoggerManager } from "./logging"

let _activeConnectionManager: CommunicationManager
let _terminationMgr: TerminationManager
Expand Down Expand Up @@ -454,12 +456,25 @@ async function startInstrDiscovery(): Promise<void> {
if (wait_time === undefined) {
return
}
const logger = LoggerManager.instance().add_logger("TSP Discovery")

if (parseInt(wait_time)) {
const term = vscode.window.createTerminal({
name: "Discovery",
shellPath: EXECUTABLE,
shellArgs: ["discover", "all", "--timeout", wait_time],
shellArgs: [
"--log-file",
path.join(
LOG_DIR,
`${new Date().toISOString().substring(0, 10)}-kic.log`
),
"--log-socket",
`${logger.host}:${logger.port}`,
"discover",
"all",
"--timeout",
wait_time,
],
iconPath: vscode.Uri.file("/keithley-logo.ico"),
})
term.show()
Expand Down
20 changes: 19 additions & 1 deletion src/instruments.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as cp from "node:child_process"
import path = require("path")

import * as vscode from "vscode"
import {
Expand All @@ -17,6 +18,8 @@ import {
IoType,
KicProcessMgr,
} from "./resourceManager"
import { LOG_DIR } from "./utility"
import { LoggerManager } from "./logging"

const DISCOVERY_TIMEOUT = 300

Expand Down Expand Up @@ -1283,10 +1286,25 @@ export class InstrumentsExplorer {
}

private startDiscovery() {
const logger = LoggerManager.instance().add_logger("TSP Discovery")
if (this.InstrumentsDiscoveryViewer.message == "") {
cp.spawn(
DISCOVER_EXECUTABLE,
["all", "--timeout", DISCOVERY_TIMEOUT.toString(), "--exit"]
[
"--log-file",
path.join(
LOG_DIR,
`${new Date()
.toISOString()
.substring(0, 10)}-kic-discover.log`
),
"--log-socket",
`${logger.host}:${logger.port}`,
"all",
"--timeout",
DISCOVERY_TIMEOUT.toString(),
"--exit",
]
//,
// {
// detached: true,
Expand Down
Loading

0 comments on commit 8dc7a1b

Please sign in to comment.