Logger class on Serial5

Hi There all

I would like to default the logger to a different serial port than those available out of the box.

How do I create a new class that has Serial5 as the logging serial port.

Thanks

Marshall

Have you tried Serial5LogHandler?
This would be my first try along the line of the documented Serial1LogHanlder

Serial5LogHandler doesn’t compile on Particle e-series and deviceOS 3.0

That’s because there never was a Serial5LogHandler provided by the device OS, but when looking at the implementation of Serial1LogHandler you can easily create your own version for Serial5 :wink:

class Serial1LogHandler: public StreamLogHandler {
public:
    explicit Serial1LogHandler(LogLevel level = LOG_LEVEL_INFO, LogCategoryFilters filters = {}) :
            Serial1LogHandler(9600, level, filters) {
    }

    explicit Serial1LogHandler(int baud, LogLevel level = LOG_LEVEL_INFO, LogCategoryFilters filters = {}) :
            StreamLogHandler(Serial1, level, filters) {
        Serial1.begin(baud);
        LogManager::instance()->addHandler(this);
    }

    virtual ~Serial1LogHandler() {
        LogManager::instance()->removeHandler(this);
        Serial1.end();
    }
};

(From the public Open Source repo)