Logging

The library has a log containing all communication with devices and all events (such as opening or closing the connection). This information may be useful, so the library offers a method to expose this internal log.

Here is an example showing the format of a typical log; TX lines are commands sent from the computer to a device, RX lines are responses received by the computer from a device:

2019/04/25 14:44:24.178885 Opening COM2
2019/04/25 14:44:24.182896 TX Line: /0 0 0:30
2019/04/25 14:44:24.196385 RX Line: @03 0 00 OK IDLE -- 0
2019/04/25 14:44:25.196684 TX Line: /3 0 1 get deviceid:6F
2019/04/25 14:44:25.203921 RX Line: @03 0 01 OK IDLE -- 50001
2019/04/25 14:44:25.204266 TX Line: /3 0 2 get version:A5
2019/04/25 14:44:25.219912 RX Line: @03 0 02 OK IDLE -- 6.29
2019/04/25 14:44:25.284002 GET https://api.zaber.io/device-db/public/device/50001?fw=6.29.1432
2019/04/25 14:44:25.434494 TX Line: /3 0 7 home:5D
2019/04/25 14:44:25.443742 RX Line: @03 0 07 OK BUSY -- 0
2019/04/25 14:44:25.444043 TX Line: /3 0 8:25
2019/04/25 14:44:25.459761 RX Line: @03 0 08 OK BUSY -- 0

To configure the library to log to standard output, call the set_log_output method:

Python
C#
C++
JavaScript
MATLAB
Java
MATLAB (legacy)
// const { Library, LogOutputMode } = require('@zaber/motion');

Library.setLogOutput(LogOutputMode.STDOUT);
# from zaber_motion import Library, LogOutputMode

Library.set_log_output(LogOutputMode.STDOUT)
Library.SetLogOutput(LogOutputMode.Stdout);
// import zaber.motion.Library;
// import zaber.motion.LogOutputMode;

Library.setLogOutput(LogOutputMode.STDOUT);
% Logging to standard output is not supported in MATLAB.
% Logging to standard output is not supported in MATLAB.
Library::setLogOutput(LogOutputMode::STDOUT);

You may also log to a file specifying a different LogOutputMode :

Python
C#
C++
JavaScript
MATLAB
Java
MATLAB (legacy)
// const { Library, LogOutputMode } = require('@zaber/motion');

Library.setLogOutput(LogOutputMode.FILE, 'motion_library_log.txt');
# from zaber_motion import Library, LogOutputMode

Library.set_log_output(LogOutputMode.FILE, "motion_library_log.txt")
Library.SetLogOutput(LogOutputMode.File, "motion_library_log.txt");
// import zaber.motion.Library;
// import zaber.motion.LogOutputMode;

Library.setLogOutput(LogOutputMode.FILE, "motion_library_log.txt");
% import zaber.motion.Library;
% import zaber.motion.LogOutputMode;

Library.setLogOutput(LogOutputMode.FILE, 'motion_library_log.txt');
% import zaber.motion.Library;
% import zaber.motion.LogOutputMode;

Library.setLogOutput(LogOutputMode.File, 'motion_library_log.txt');
Library::setLogOutput(LogOutputMode::FILE, "motion_library_log.txt");

Currently, the library does not provide a way to send the log to the application program. If you want to process the log, we recommend logging to a file and then reading from it. Contact us if this feature may be desirable for you, as we may consider adding it in future versions.

Binary Protocol

For Binary Protocol, the logging prints numeric representation of the messages.

2019/09/06 14:32:46.470692 Opening COM2
2019/09/06 14:32:46.471456 Read loop started
2019/09/06 14:32:46.471806 TX Line: [0 50 0 0 0 0]
2019/09/06 14:32:46.486557 RX Line: [2 50 14 118 0 0]
2019/09/06 14:32:46.486658 Response {2 50 0 30222} matches command: {0 50 0 0}
2019/09/06 14:32:46.502363 RX Line: [3 50 14 118 0 0]
2019/09/06 14:32:46.502391 Response {3 50 0 30222} matches command: {0 50 0 0}
2019/09/06 14:32:47.002945 TX Line: [2 50 0 0 0 0]
2019/09/06 14:32:47.030225 RX Line: [2 50 14 118 0 0]
2019/09/06 14:32:47.030259 Response {2 50 0 30222} matches command: {2 50 0 0}
2019/09/06 14:32:47.094364 TX Line: [2 53 66 0 0 0]
2019/09/06 14:32:47.110168 RX Line: [2 66 90 172 0 0]
2019/09/06 14:32:47.110197 Response {2 66 0 44122} matches command: {2 53 0 66}
2019/09/06 14:32:47.110379 GET https://api.zaber.io/device-db/public/device-binary/30222?fw=6.30.1488&peripheral=44122
2019/09/06 14:32:47.254598 TX Line: [3 50 0 0 0 0]
2019/09/06 14:32:47.270118 RX Line: [3 50 14 118 0 0]
2019/09/06 14:32:47.270145 Response {3 50 0 30222} matches command: {3 50 0 0}