There can be any number of Message Subscribers, whose job is to receive (and usually output) published messages. Trick automatically creates three Message Subscribers:
When you publish a message, it will be output by the three subscribers above.
A subscriber can be enabled / disabled at any time during simulation execution to output / ignore messages as desired.
The user may also add their own subscriber by creating a derived class from `Trick::MessageSubscriber`.
-`Trick::MessageThreadedCout` - outputs messages to the standard output stream asynchronously.
The `MessageThreadedCout` class is included with the simulation but not activated by default. When activated messages will be written to the standard output stream like `MessageCout`, but internally we use a separate thread to do the writing. This helps real-time performance.
`trick_message.separate_thread_set_enabled(True)` - turns on outputting messages to the standard output stream on a separate thread while turning off outputting messages to the standard output stream on the same thread and Sim Control Panel
`trick_message.separate_thread_set_enabled(False)` - turns off outputting messages to the standard output stream on a separate thread while turning on outputing messages to the standard output stream on the same thread and Sim Control Panel
The level number can be any number greater than or equal to 0. Levels 0-99 are captured by Trick's default message subscribers. Trick has a few predefined levels (`Trick::MessagePublisher::MESSAGE_TYPE`) that it uses for publishing messages.
int open_custom_message_file(std::string file_name, std::string subscriber_name, int level = -1);
```
This function opens a new file, adds it to the list of message subscribers, and returns the level that can be used to write to the file.
A user can specify a level >= 0. If `open_custom_message_file` is called without a level argument, the function will assign a unique level to the file that is >= 100. If a user wants the messages written to this file to also be captured by default Trick message subscribers, they should specify a level from 0-99.
Example:
```cpp
// Open the logfile
int my_level = open_custom_message_file("my_log_dir/logfile", "custom_log");
// Write to it by publishing a message with the given level
message_publish(my_level, "This message will be written to my custom logfile");
By default these are all subscribed. You can use subscribe/unsubscribe throughout a simulation to turn on/off messages at will.
```python
trick.message_unsubscribe(trick_message.mcout)
trick.message_unsubscribe(trick_message.mdevice)
trick.message_unsubscribe(trick_message.mfile)
```
To enable / disable Trick's default subscribers:
By default these are all enabled. If you disable `file` at startup, the `send_hs` file will not be created/opened. If you disable `device` at startup, its connection will not be established.
That means you cannot then later try to enable and subscribe to file/device.