https://github.com/Microsoft/CNTK
Raw File
Tip revision: 7bf32d16f58ec13366aad67136e92ca4d85a53c9 authored by liqfu on 22 October 2018, 01:34:23 UTC
ready for seq ops
Tip revision: 7bf32d1
Logger.h
#pragma once

#include <ostream>
#include <sstream>
#include <string>
#include <iostream>

#include "core/common/logging/capture.h"
#include "core/common/logging/isink.h"

namespace CNTK {
class CNTKClogSink : public onnxruntime::Logging::ISink {
public:
    CNTKClogSink()
        : stream_{&(std::clog)}, flush_{true}
    {}

    void SendImpl(const onnxruntime::Logging::Timestamp &timestamp, 
        const std::string &logger_id, const onnxruntime::Logging::Capture &message) override
    {
        UNUSED_PARAMETER(timestamp);

        std::ostringstream msg;

        msg << " [" << message.SeverityPrefix() << ":" << message.Category() << ":" << logger_id << ", "
            << message.Location().ToString() << "] " << message.Message();

        (*stream_) << msg.str() << "\n";

        if (flush_) {
            stream_->flush();
        }
    }

private:
    std::ostream *stream_;
    const bool flush_;
};
} // namespace CNTK
back to top