qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chuck Rolke <cro...@redhat.com>
Subject Re: Qpid Client API logging
Date Mon, 07 Jul 2014 12:52:10 GMT
Hi Andreas,

In release 0.28 full client logging-control was included.

See https://reviews.apache.org/r/16316/

Examples of the controls available are in the "View Diff", file src/tests/MessagingLogger.cpp

If you are running an older release try to apply this patch and use this logging interface.
Then your migration to a current version will be much easier.

-Chuck

----- Original Message -----
> From: "Andreas Welchlin" <andreas.welchlin@comyno.com>
> To: users@qpid.apache.org
> Sent: Monday, July 7, 2014 7:28:21 AM
> Subject: Qpid Client API logging
> 
> Hi All,
> 
> Sometimes I find it very useful to switch the client api logging on.
> 
> The user interface is powerful but also not too comfortable.
> So what about providing a little interface for easy usage as an example
> in the next Qpid release?
> 
> Maybe something like this header file QpidApiLogger.h:
> 
> 
> #ifndef OWN_QPID_API_LOGGER_H
> #define OWN_QPID_API_LOGGER_H
> 
> #include <qpid/messaging/Logger.h>
> 
> #include <string>
> #include <vector>
> #include <exception>
> 
> namespace helper {
> 
> /**
>   * Helper class which makes it easy to switch on logging of Qpid Client
> API.
>   */
> class QpidApiLogger
> {
> public:
>      enum LOG_LEVEL {LVL_TRACE, LVL_DEBUG, LVL_INFO, LVL_NOTICE,
> LVL_WARNING, LVL_ERROR, LVL_CRITICAL};
> public:
>      /**
>       *  Switches Qpid Client API logging on.
>       *  @param filename - the path to write to
>       *  @param level - the loglevel
>       *  @throw UsrException - if loglevel is wrong
>       */
>      static void enableLogging(const std::string &filename, LOG_LEVEL level)
>      {
>          enableLogging(filename, toString(level));
>      }
> 
>      /**
>       * Same as above but with level as a string.
>       * @param filename - the path to write to
>       * @param level - "trace+", "debug+", "info+", "notice+",
> "warning+", "error+", "critical+"
>       */
>      static void enableLogging(const std::string &filename, const
> std::string &level)
>      {
>          std::vector<const char*> arguments;
>          arguments.push_back("this_argument_is_ignored");
>          arguments.push_back("--log-to-file");
>          arguments.push_back(filename.c_str());
>          arguments.push_back("--log-enable");
>          arguments.push_back(level.c_str());
>          arguments.push_back(NULL);
>          qpid::messaging::Logger::configure(arguments.size()-1,
> &arguments[0]);
>      }
> 
>      /**
>       * converts given level to a string
>       */
>      static const std::string toString(LOG_LEVEL level)
>      {
>          switch (level) {
>          case LVL_TRACE:    return "trace+";
>          case LVL_DEBUG:   return "debug+";
>          case LVL_INFO:      return "info+";
>          case LVL_NOTICE:  return "notice+";
>          case LVL_WARNING:  return "warning+";
>          case LVL_ERROR:    return "error+";
>          case LVL_CRITICAL: return "critical+";
>          default:
>              throw std::invalid_argument("wrong argument: " + level);
>          }
>      }
> };
> 
> } // end namespace
> #endif
> 
> Regards,
> Andreas
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Mime
View raw message