OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  8.1.0
API documentation
HandlerLogger.cpp
Go to the documentation of this file.
1 /*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19 
20 #include "HandlerLogger.h"
21 
22 #if defined(_DEBUG) && defined(WIN32) && defined(DEBUG_MEM)
23 #undef new
24 #define new DEBUG_NEW
25 #endif
26 
27 using namespace std;
28 
29 namespace OnixS {
30 namespace Eurex {
31 namespace MarketData {
32 namespace Implementation {
33 
34 char last (const std::string &str)
35 {
36  if(size_t len = str.length())
37  return str[len - 1];
38 
39  return 0;
40 }
41 
42 template<size_t N>
43 bool oneof(const char c, const char( &literal)[N])
44 {
45  for(int i = N; i; i--)
46  if(c == literal[i])
47  return true;
48 
49  return false;
50 }
51 
52 
54 {
55  o.appendNoIndent("*", 1);
56  return o;
57 }
58 
59 
61 {
62  return o << name << '=';
63 }
64 
65 // take string in quotes
66 TextBuilder & operator<<(TextBuilder & o, const VarFormatHelper<ValuePtr> & var)
67 {
68  format_var_name(o, var.name);
69 
70  if(var.value.length_)
71  return o << "\"" << var.value << "\"";
72 
73  return format_nullptr_value(o);
74 }
75 
76 // take char in quotes
77 TextBuilder & operator<<(TextBuilder & o, const VarFormatHelper<char> & var)
78 {
79  format_var_name(o, var.name);
80 
81  if(var.value)
82  return o << "'" << var.value << "'";
83 
84  return format_nullptr_value(o);
85 }
86 
88  HandlerCore::Common::HandlerLogger* logger, OnixS::Logging::LogFacility *logFacility, const char *contextName) ONIXS_NOEXCEPT
89 {
90  BOOST_ASSERT(logger != nullptr);
91  BOOST_ASSERT(logFacility != nullptr);
92  BOOST_ASSERT(contextName != nullptr);
93 
94  try
95  {
96  throw;
97  }
98  catch(const std::exception &ex)
99  {
100  logger->log( ONIXS_LOG_ERROR[logFacility] << "Exception inside " << contextName << " callback: " << ex.what());
101  }
102  catch(...)
103  {
104  logger->log( ONIXS_LOG_ERROR[logFacility] << "Unknown exception inside " << contextName << " callback.");
105  }
106 }
107 
108 }}}}
109 
STL namespace.
Util::TextBuilder TextBuilder
Definition: Formatting.h:43
char last(const std::string &str)
TextBuilder & format_var_name(TextBuilder &o, ValuePtr name)
Definition: Defines.h:30
void userExceptionHandler(HandlerCore::Common::HandlerLogger *, OnixS::Logging::LogFacility *, const char *contextName) ONIXS_NOEXCEPT
TextBuilder & format_nullptr_value(TextBuilder &o)
bool oneof(const char c, const char(&literal)[N])