Integrate logger client into cdp-client with service-based discovery#27
Integrate logger client into cdp-client with service-based discovery#27stefanrammo merged 45 commits intomainfrom
Conversation
Initial implementation: logger, example usage, and tests
A test for Events using the example case in CDP Studio
This reverts commit cbea695.
Added event support
Fixes for added event support
Event data handling
Match type added and restructuring client.js
…ancies Fix documentation
…e-detection Add automatic detection to client.js between Node.js or browser
|
The bundled logger client is adapted from https://github.com/CDPTechnologies/JavascriptCDPLoggerClient with these changes to support integration:
|
There was a problem hiding this comment.
Were there any changes to this file? It would be better to make bringing in existing code a separate commit, so it would be easier to review the actual changes done after that.
By the way, we have a guide in our wiki how to merge repositories (or some files from a repository) while keeping commit history, search for the "Git tips & tricks" page. Then the development log of the logger client will be preserved.
index.js
Outdated
| /** | ||
| * Get a logger client via service-based discovery and proxy transport (CDP 5.1+). | ||
| * @param {string} [name] - Logger service name (node path) to filter by. | ||
| * @param {Object} [options] - Options. |
There was a problem hiding this comment.
[options] - Options. - just repeating the argument name is not useful
index.js
Outdated
| } | ||
|
|
||
| /** | ||
| * Get a logger client via service-based discovery and proxy transport (CDP 5.1+). |
There was a problem hiding this comment.
I think the doc should describe more what one can do with the logger client (query historic data) not how it was found. Should keep the CDP 5.1+ comment though
index.js
Outdated
| * Get a logger client via service-based discovery and proxy transport (CDP 5.1+). | ||
| * @param {string} [name] - Logger service name (node path) to filter by. | ||
| * @param {Object} [options] - Options. | ||
| * @param {number} [options.timeout] - Timeout in milliseconds. Rejects if no matching service appears in time. |
There was a problem hiding this comment.
What happens when timeout is not specified?
There was a problem hiding this comment.
Indefinite wait for server event using 2s sibling polling.
index.js
Outdated
| reject("Logger service discovery requires CDP 5.1+"); | ||
| return; | ||
| } | ||
| var service = primary.findLoggerService(name); |
There was a problem hiding this comment.
Does it also look for logger services from other sibling applications?
In case there are multiple apps in the system, the connection to logger can be "tunneled twice", e.g. StudioAPI client -> MainApp -> LoggerApp -> CDPLogger server.
There was a problem hiding this comment.
Changed it, it searches all connections now
README.rst
Outdated
| Auto-discovers the first available CDPLogger or LogServer via service discovery, | ||
| creates a proxy transport, and returns a ready-to-use logger client. Repeated calls | ||
| return the same cached instance. A cached logger whose transport has closed is evicted | ||
| on the next call. |
There was a problem hiding this comment.
Should explain why is it relevant to the user when the cached call is evicted
| For more information about CDP Logger, see https://cdpstudio.com/manual/cdp/cdplogger/cdplogger-index.html. | ||
|
|
||
| Logger data is served behind StudioAPI authentication and tunneled through the | ||
| existing proxy connection. |
There was a problem hiding this comment.
Should have somewhere also a longer description. Either in this file or a different file. The https://github.com/CDPTechnologies/JavascriptCDPLoggerClient/blob/main/DOCUMENTATION.md had a good overview and some background into what the logger can do.
And I also liked the examples folder in the logger client repo, maybe should copy those also over here.
Merge JavascriptCDPLoggerClient repository into logger/ with full commit history preserved. All files imported unchanged. Source: https://github.com/CDPTechnologies/JavascriptCDPLoggerClient
e8addfd to
d4d7903
Compare
index.js
Outdated
| * Discovers loggers from all applications in the system, including | ||
| * sibling apps connected via proxy. | ||
| * @param {string} [name] - Logger service name to filter by, e.g. "App.CDPLogger". | ||
| * @param {number} [options.timeout] - Timeout in milliseconds. Without timeout, waits indefinitely until a matching logger appears. |
There was a problem hiding this comment.
Should mention that timeout 0 means immediate fail if logger was not found.
logger/LICENSE
Outdated
| @@ -0,0 +1,21 @@ | |||
| MIT License | |||
|
|
|||
| Copyright (c) 2025 CDP Technologies | |||
README.rst
Outdated
| to manually discover the logger port or manage a separate WebSocket connection. | ||
| For more information about CDP Logger, see https://cdpstudio.com/manual/cdp/cdplogger/cdplogger-index.html. | ||
| For background on the data query protocol, time synchronization, and API version | ||
| history, see `logger/DOCUMENTATION.md <logger/DOCUMENTATION.md>`_. Runnable |
There was a problem hiding this comment.
Make sure to test that this link still works after pushing the code to npm
Bundle cdplogger-client as studio.logger and add client.logger() method that discovers loggers via ServicesNotification and connects through proxy transport via makeServiceTransport (CDP 5.1+). - client.logger(name, options): auto-discovers logserver proxy service across all connections including sibling apps via proxy - client.loggers(): returns all discovered logger services - Sibling app discovery: searches all AppConnections, not just primary; serviceUpdateListeners fire on all connections; poll interval catches new siblings that appear after initial listener registration - Dead connection guard: isConnectionAlive() skips connections whose transport is closed, preventing stale service discovery - Caching by name with eviction on transport close; stale promise cleanup via .then(clearPromise, clearPromise) on both resolve/reject - close() disconnects cached loggers and rejects pending promises - Error() rejections matching existing find()/onConnect() patterns - Proto files use raw .proto.js format matching studioapi.proto.js - Standalone files from import removed (client.js, package.json, generated/, test/, .github/, QUICKSTART.md, README.md) - DOCUMENTATION.md updated for bundled context - Unit tests adapted from cdplogger-client test suite - README.rst Logger Integration section with API docs and examples - Examples (event.js, value.js) updated for proxy-based discovery
d4d7903 to
447cc35
Compare
Bundle cdplogger-client as studio.logger and add client.logger() method that discovers loggers via ServicesNotification and connects through proxy transport via makeServiceTransport (CDP 5.1+).