{"library":"probe.gl","title":"probe.gl Instrumentation and Logging","description":"probe.gl is a robust collection of JavaScript tools designed for console-focused logging, performance instrumentation, benchmarking, and testing across both browser and Node.js environments. The current stable version is 3.6.0. It is developed and maintained as part of the vis.gl open-source visualization suite by Uber, indicating a steady release cadence tied to the evolution of their larger ecosystem. Key differentiators include its 'off by default' design to ensure a minimal performance footprint when not actively used, its lightweight nature, and features like persistent configuration through local storage. It enhances the debugging experience with capabilities such as defeating log cascades (to prevent console flooding) and providing direct source code links from console messages. The library offers a more advanced approach to application insights compared to basic `console.log`.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install probe.gl"],"cli":null},"imports":["import Probe from 'probe.gl';","import { log } from '@probe.gl/log';","import { Timer } from '@probe.gl/stats';","import Probe from 'probe.gl';\nwindow.Probe = Probe;"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import Probe from 'probe.gl';\nimport { log } from '@probe.gl/log';\nimport { Timer } from '@probe.gl/stats';\n\n// 1. Enable Probe and set logging level\n// Probe is 'off by default' to minimize performance impact.\nProbe.enable().setLevel(3); // Enable all features and verbose logging\nProbe.configure({ isPrintEnabled: true }); // Ensure messages are printed to console\n\nconsole.log('Probe.gl initialized. Check browser console for detailed logs.');\n\n// 2. Use basic logging utilities\nlog.log('Application started successfully.');\nlog.warn('A non-critical issue detected.', { code: 101, details: 'Example warning payload' });\nlog.error('Failed to load critical resource!', new Error('Resource not found'));\n\n// 3. Measure performance with a Timer\nconst myTimer = new Timer('ExpensiveOperation');\n\nfunction performExpensiveOperation() {\n  myTimer.start();\n  // Simulate some work\n  let sum = 0;\n  for (let i = 0; i < 1000000; i++) {\n    sum += Math.sqrt(i);\n  }\n  myTimer.end(); // Automatically logs duration if Probe is enabled\n  log.log(`Result of expensive operation: ${sum}`);\n}\n\nperformExpensiveOperation();\n\n// 4. Using the main Probe object for options\nif (Probe.getOption('myFeatureFlag')) {\n  log.log('Custom feature flag \\'myFeatureFlag\\' is enabled.');\n} else {\n  log.log('Custom feature flag \\'myFeatureFlag\\' is disabled, configuring it...');\n  Probe.configure({ myFeatureFlag: true });\n  log.log('Custom feature flag \\'myFeatureFlag\\' is now enabled for subsequent checks.');\n}\n","lang":"typescript","description":"Demonstrates enabling probe.gl, setting log levels, using logging utilities, and basic performance timing with a `Timer`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}