// // Logging.h // libraries/networking/src // // Created by Stephen Birarda on 6/11/13. // Copyright 2013 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_Logging_h #define hifi_Logging_h #include const int LOGSTASH_UDP_PORT = 9500; const char LOGSTASH_HOSTNAME[] = "graphite.highfidelity.io"; const char STAT_TYPE_TIMER = 't'; const char STAT_TYPE_COUNTER = 'c'; const char STAT_TYPE_GAUGE = 'g'; class HifiSockAddr; /// Handles custom message handling and sending of stats/logs to Logstash instance class Logging { public: /// \return the socket used to send stats to logstash static const HifiSockAddr& socket(); /// checks if this target should send stats to logstash, given its current environment /// \return true if the caller should send stats to logstash static bool shouldSendStats(); /// stashes a float value to Logstash instance /// \param statType a stat type from the constants in this file /// \param key the key at which to store the stat /// \param value the value to store static void stashValue(char statType, const char* key, float value); /// sets the target name to output via the verboseMessageHandler, called once before logging begins /// \param targetName the desired target name to output in logs static void setTargetName(const QString& targetName) { _targetName = targetName; } /// a qtMessageHandler that can be hooked up to a target that links to Qt /// prints various process, message type, and time information static void verboseMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message); private: static HifiSockAddr _logstashSocket; static QString _targetName; }; #endif // hifi_Logging_h