Skip to content

Commit 131299c

Browse files
committed
Remove console.log, add skill
1 parent b058585 commit 131299c

3 files changed

Lines changed: 57 additions & 3 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Skill: Use log.debug Instead of console.log
2+
3+
When adding debug logging in JavaScript/TypeScript files in this codebase, use the `@deephaven/log` module instead of `console.log` or `console.debug`.
4+
5+
## Pattern
6+
7+
1. **Import the Log module** at the top of the file:
8+
```typescript
9+
import Log from '@deephaven/log';
10+
```
11+
12+
2. **Create a module-specific logger** after imports:
13+
```typescript
14+
const log = Log.module('ModuleName');
15+
```
16+
Replace `'ModuleName'` with the name of the current file/module (e.g., `'ChartUtils'`, `'TableUtils'`).
17+
18+
3. **Use the logger** for debug output:
19+
```typescript
20+
log.debug('message', data);
21+
log.debug2('more verbose message', data); // For very verbose logging
22+
```
23+
24+
## Why
25+
26+
- Consistent logging across the codebase
27+
- Log levels can be configured at runtime
28+
- Module-specific filtering is possible
29+
- Avoids ESLint `no-console` warnings
30+
- Better production behavior (logs can be silenced)
31+
32+
## Example
33+
34+
```typescript
35+
import Log from '@deephaven/log';
36+
37+
const log = Log.module('MyComponent');
38+
39+
function processData(data: SomeType): void {
40+
log.debug('Processing data:', data);
41+
// ... processing logic
42+
log.debug2('Detailed step completed');
43+
}
44+
```
45+
46+
## Avoid
47+
48+
```typescript
49+
// ❌ Don't use console directly
50+
console.log('Processing data:', data);
51+
console.debug('Step completed');
52+
53+
// ❌ Don't add eslint-disable for console
54+
// eslint-disable-next-line no-console
55+
console.log('debug info');
56+
```

packages/dashboard-core-plugins/src/GridWidgetPlugin.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ export function GridWidgetPlugin({
159159
);
160160
}
161161

162-
console.log('[0]');
163-
164162
assertNotNull(model, 'Model should be defined when fetch is successful');
165163

166164
return (

packages/dashboard-core-plugins/src/panels/WidgetPanelTooltip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function WidgetPanelTooltip(props: WidgetPanelTooltipProps): ReactElement {
99

1010
// Convert PascalCase to Title Case
1111
// ex. PartitionedTable -> Partitioned Table
12-
const formattedType = type.replace(/([a-z])([A-Z])/g, '$1 $2');
12+
const formattedType = type?.replace(/([a-z])([A-Z])/g, '$1 $2') ?? '';
1313

1414
return (
1515
<div className="tab-tooltip-grid-container">

0 commit comments

Comments
 (0)