Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
172f775
Initial commit
Karmo7 Mar 19, 2025
6e5c935
Update README.md
Karmo7 Mar 19, 2025
671a042
Initial implementation: logger, example usage, and tests
stefanrammo Mar 20, 2025
96c1f87
Merge pull request #1 from stefanrammo/main
stefanrammo Mar 20, 2025
cbea695
Added support for Events and a test
stefanrammo Mar 23, 2025
a5b4810
Revert "Added support for Events and a test"
stefanrammo Mar 23, 2025
9d10355
Added support for Events and a test
stefanrammo Mar 23, 2025
7853884
Refactored event into a seperate example file
stefanrammo Mar 23, 2025
f3a7845
Updated README.md
stefanrammo Mar 23, 2025
d30440c
Fixed bugs
stefanrammo Mar 24, 2025
6ef60ca
Merge pull request #4 from CDPTechnologies/AddedEventSupport
stefanrammo Mar 24, 2025
0d8b2f0
Fixed pull request issues
stefanrammo Mar 24, 2025
2cf2c24
Added sender and data conditions to event example
stefanrammo Mar 25, 2025
423fedd
Merge pull request #5 from CDPTechnologies/FixesForAddedEventSupport
stefanrammo Mar 25, 2025
b51959b
Pull review #5 issues fixed
stefanrammo Mar 26, 2025
a6746e3
Added getEventCodeString method
stefanrammo Mar 26, 2025
44133d4
Fixed comments
stefanrammo Mar 26, 2025
c0b9fce
Merge pull request #6 from CDPTechnologies/EventDataHandling
stefanrammo Mar 27, 2025
e912ad4
Match type added and restructuring client.js
stefanrammo Mar 27, 2025
29a78d4
Merge pull request #7 from CDPTechnologies/MatchTypeFix
stefanrammo Mar 31, 2025
bdd29ee
Changed documentation and added objects: EventQueryFlags and MatchType
stefanrammo Mar 31, 2025
0a7c4f1
Formatting
stefanrammo Mar 31, 2025
6511630
Added Event Tags support and Count Events
stefanrammo Apr 1, 2025
1b3465a
Added tests and fake data related to Event Tags
stefanrammo Apr 1, 2025
bec0606
Wrapped Client in a namespace cdplogger.Client
stefanrammo Apr 2, 2025
0512a8a
Add GitHub Actions workflow for running tests
stefanrammo Apr 3, 2025
50d5262
Update workflow to handle missing test directories
stefanrammo Apr 3, 2025
cc9d10c
Simplify workflow to run on single Node.js version
stefanrammo Apr 3, 2025
4df8074
Add working GitHub Actions workflow for running tests
stefanrammo Apr 3, 2025
3ebf57d
Added automatic test workflow
stefanrammo Apr 3, 2025
189a984
Removed hardcoded port adding to url
stefanrammo Apr 4, 2025
f03f42f
Created a markdown file for docs and a quick start guide
stefanrammo Apr 7, 2025
bce99c9
Fixed documentation mistakes
stefanrammo Apr 8, 2025
f6aa706
NPM setup
stefanrammo Apr 10, 2025
dc2dad6
Updated package.json
stefanrammo Apr 10, 2025
b182d64
Added contacts to README
stefanrammo Apr 10, 2025
15621e0
Updated docs
stefanrammo Apr 10, 2025
3fdaba7
Changed name from cdp-logger-client to cdplogger-client
stefanrammo Apr 10, 2025
2845852
Publish version 1.0.2 and update package.json and README
stefanrammo Apr 28, 2025
67a6a55
Fix documentation
stefanrammo Jun 18, 2025
5c158f8
Merge pull request #13 from CDPTechnologies/fix-documentation-discrep…
stefanrammo Jun 18, 2025
62136b6
Add automatic detection to client.js between Node.js or browser
stefanrammo Jun 19, 2025
bd73418
Merge pull request #14 from CDPTechnologies/add-automatic-browser-nod…
stefanrammo Jun 19, 2025
36bc568
Import cdplogger-client into logger/ subdirectory
stefanrammo Apr 9, 2026
447cc35
Integrate logger client into cdp-client with service-based discovery
stefanrammo Apr 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -801,3 +801,170 @@ node.removeChild(name)

Remove child Node from this Node.

Logger Integration (CDP 5.1+)
-----------------------------

The CDP Logger client is bundled into ``cdp-client`` as ``studio.logger``. Logger
discovery and connection is handled automatically via the StudioAPI proxy — no need
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 <https://github.com/CDPTechnologies/JavascriptCDPClient/blob/main/logger/DOCUMENTATION.md>`_. Runnable
examples are in `logger/examples/ <https://github.com/CDPTechnologies/JavascriptCDPClient/tree/main/logger/examples>`_.

Logger data is served behind StudioAPI authentication and tunneled through the
existing proxy connection.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


client.logger(name, options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Arguments

name (optional) - Logger service name (node path) to filter by, e.g. ``"App.CDPLogger"``

options (optional) - ``{ timeout: number }`` Timeout in milliseconds. Rejects if no matching service appears in time.

- Returns

Promise.<LoggerClient> - Resolves with a connected logger client instance.

- Usage

Returns a logger client for querying historic data and events. The logger
is discovered automatically from all applications in the system, including
sibling apps connected via proxy. Without a timeout, waits indefinitely
until a matching logger appears. Repeated calls return the same instance.

- Example

.. code:: javascript

const studio = require("cdp-client");
const client = new studio.api.Client("127.0.0.1:7689");

// Auto-discover any available logger
client.logger().then(function(logger) {
return logger.requestLogLimits().then(function(limits) {
return logger.requestDataPoints(
["Temperature", "Pressure"],
limits.startS, limits.endS, 200, 0
);
}).then(function(points) {
points.forEach(function(p) {
var temp = p.value["Temperature"];
console.log(new Date(p.timestamp * 1000), "min:", temp.min, "max:", temp.max);
});
});
});

.. code:: javascript

// Discover a specific logger by name
client.logger("App.CDPLogger").then(function(logger) {
return logger.requestLoggedNodes().then(function(nodes) {
console.log("Logged nodes:", nodes.map(function(n) { return n.name; }));
});
});

.. code:: javascript

// Query events
client.logger().then(function(logger) {
return logger.requestEvents({
limit: 100,
flags: studio.logger.Client.EventQueryFlags.NewestFirst
}).then(function(events) {
events.forEach(function(e) {
console.log(e.sender, e.data);
});
});
});

.. code:: javascript

// With timeout — rejects if no logger found within 5 seconds
client.logger("App.CDPLogger", { timeout: 5000 }).catch(function(err) {
console.log(err); // "Timeout: no logger service found for 'App.CDPLogger'"
});

client.loggers()
^^^^^^^^^^^^^^^^

- Returns

Promise.<Array.<{name, metadata}>> - All available logger services. Waits for
service discovery if none have been received yet.

- Usage

Returns the list of all discovered logger services. Each entry has ``name``
(the logger's node path) and ``metadata`` (service metadata including ``proxy_type``).

- Example

.. code:: javascript

client.loggers().then(function(loggers) {
loggers.forEach(function(l) {
console.log(l.name, l.metadata.proxy_type); // "App.CDPLogger" "logserver"
});
});

studio.logger.Client
~~~~~~~~~~~~~~~~~~~~

The logger client class is also available as ``studio.logger.Client`` for standalone
usage when the logger endpoint is already known.

Node.js
"""""""

In Node.js, the logger client is loaded automatically:

.. code:: javascript

const studio = require("cdp-client");
var loggerClient = new studio.logger.Client("127.0.0.1:17000");

Browser
"""""""

In the browser, load the proto files and logger client before ``index.js``:

.. code:: html

<script src="protobuf.min.js"></script>
<script src="logger/variant.proto.js"></script>
<script src="logger/database.proto.js"></script>
<script src="logger/container.proto.js"></script>
<script src="logger/logger-client.js"></script>
<script src="index.js"></script>

Then use via ``studio.logger.Client``:

.. code:: javascript

var loggerClient = new studio.logger.Client(window.location.hostname + ":17000");

Static properties:

- ``studio.logger.Client.EventQueryFlags`` - ``{ None: 0, NewestFirst: 1, TimeRangeBeginExclusive: 2, TimeRangeEndExclusive: 4, UseLogStampForTimeRange: 8 }``
- ``studio.logger.Client.MatchType`` - ``{ Exact: 0, Wildcard: 1 }``

LoggerClient API
~~~~~~~~~~~~~~~~

The logger client returned by ``client.logger()`` provides these methods:

- ``requestApiVersion()`` - Returns Promise with the logger API version string.
- ``requestLoggedNodes()`` - Returns Promise with array of ``{ name, routing, tags }`` for each logged signal.
- ``requestLogLimits()`` - Returns Promise with ``{ startS, endS }`` — the earliest and latest logged timestamps in seconds.
- ``requestDataPoints(nodeNames, startS, endS, noOfDataPoints, limit)`` - Returns Promise with array of data points. Each point has ``{ timestamp, value }`` where value maps signal names to ``{ min, max, last }``.
- ``requestEvents(query)`` - Returns Promise with array of events. Query supports ``limit``, ``offset``, ``flags``, ``timeRangeBegin``, ``timeRangeEnd``, ``codeMask``, ``senderConditions``, ``dataConditions``.
- ``countEvents(query)`` - Returns Promise with the count of matching events.
- ``getEventCodeDescription(code)`` - Returns human-readable description for an event code (e.g. ``"AlarmSet + SourceObjectUnavailable"``).
- ``getEventCodeString(code)`` - Returns compact event code string (e.g. ``"RepriseAlarmSet"``, ``"Ack"``).
- ``getSenderTags(sender)`` - Returns Promise with tags for an event sender.
- ``disconnect()`` - Closes the connection and disables auto-reconnect.
- ``setEnableTimeSync(enable)`` - Enable or disable automatic time synchronization with the server.

Loading
Loading