Commit 2fb4b729efb278b6b7869dbc508f29d58fae67a0

Authored by Hu Chunming
1 parent c3c38c3c

修复日志编码问题

src/decoder/gb28181/sip/Message/CatalogParser.cpp
@@ -30,7 +30,7 @@ bool CCatalogParser::Encode( std::string &message ) @@ -30,7 +30,7 @@ bool CCatalogParser::Encode( std::string &message )
30 30
31 for( auto it = m_devices.begin(); it != m_devices.end(); ++it ) 31 for( auto it = m_devices.begin(); it != m_devices.end(); ++it )
32 { 32 {
33 - // У��Ŀ¼��ı�ѡ���� 33 + // 校验目录项的必选参数
34 const DeviceInfo &catalog = (*it); 34 const DeviceInfo &catalog = (*it);
35 content<<"<Item>\r\n"; 35 content<<"<Item>\r\n";
36 content<<"<DeviceID>"<<catalog.id<<"</DeviceID>\r\n"; 36 content<<"<DeviceID>"<<catalog.id<<"</DeviceID>\r\n";
@@ -173,7 +173,7 @@ bool CCatalogParser::Encode( std::string &amp;message ) @@ -173,7 +173,7 @@ bool CCatalogParser::Encode( std::string &amp;message )
173 std::vector< DeviceInfo > CCatalogParser::Decode( const std::vector< tinyxml2::XMLNode* > &nodes) 173 std::vector< DeviceInfo > CCatalogParser::Decode( const std::vector< tinyxml2::XMLNode* > &nodes)
174 { 174 {
175 std::vector< DeviceInfo > cat_list; 175 std::vector< DeviceInfo > cat_list;
176 - // �������У�� 176 + // 必须参数校验
177 tinyxml2::XMLNode *pSumNum = NULL; 177 tinyxml2::XMLNode *pSumNum = NULL;
178 size_t size = nodes.size(); 178 size_t size = nodes.size();
179 for( size_t i = 0; i < size; ++i ) 179 for( size_t i = 0; i < size; ++i )
@@ -181,14 +181,14 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X @@ -181,14 +181,14 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X
181 tinyxml2::XMLNode *pNode = nodes[i]; 181 tinyxml2::XMLNode *pNode = nodes[i];
182 if( pNode == NULL ) 182 if( pNode == NULL )
183 { 183 {
184 - LOG_DEBUG( "��������" ); 184 + LOG_DEBUG( "参数错误" );
185 continue; 185 continue;
186 } 186 }
187 187
188 const char* type = pNode->Value(); 188 const char* type = pNode->Value();
189 if( type == NULL ) 189 if( type == NULL )
190 { 190 {
191 - LOG_DEBUG( "��������Ϊ��" ); 191 + LOG_DEBUG( "参数名字为空" );
192 continue; 192 continue;
193 } 193 }
194 194
@@ -198,28 +198,28 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X @@ -198,28 +198,28 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X
198 } 198 }
199 } 199 }
200 200
201 - // ��ѡ���������� 201 + // 必选参数必须填
202 if( pSumNum == NULL ) 202 if( pSumNum == NULL )
203 { 203 {
204 - LOG_ERROR( "����SumNumû�б�����" ); 204 + LOG_ERROR( "参数SumNum没有被设置" );
205 return cat_list; 205 return cat_list;
206 } 206 }
207 207
208 - // �������� 208 + // 参数解析
209 std::list< tinyxml2::XMLNode* > items; 209 std::list< tinyxml2::XMLNode* > items;
210 for( size_t i = 0; i < size; ++i ) 210 for( size_t i = 0; i < size; ++i )
211 { 211 {
212 tinyxml2::XMLNode *pNode = nodes[i]; 212 tinyxml2::XMLNode *pNode = nodes[i];
213 if( pNode == NULL ) 213 if( pNode == NULL )
214 { 214 {
215 - LOG_DEBUG( "��������" ); 215 + LOG_DEBUG( "参数错误" );
216 continue; 216 continue;
217 } 217 }
218 218
219 const char* type = pNode->Value(); 219 const char* type = pNode->Value();
220 if( type == NULL ) 220 if( type == NULL )
221 { 221 {
222 - LOG_DEBUG( "��������Ϊ��" ); 222 + LOG_DEBUG( "参数名字为空" );
223 continue; 223 continue;
224 } 224 }
225 225
@@ -228,14 +228,14 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X @@ -228,14 +228,14 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X
228 tinyxml2::XMLNode *pChild = pNode->FirstChild(); 228 tinyxml2::XMLNode *pChild = pNode->FirstChild();
229 if( pChild == NULL ) 229 if( pChild == NULL )
230 { 230 {
231 - LOG_DEBUG( "����ֵû������" ); 231 + LOG_DEBUG( "参数值没有设置" );
232 continue; 232 continue;
233 } 233 }
234 234
235 const char *value = pChild->Value(); 235 const char *value = pChild->Value();
236 if( value == NULL ) 236 if( value == NULL )
237 { 237 {
238 - LOG_DEBUG( "����ֵΪ��" ); 238 + LOG_DEBUG( "参数值为空" );
239 continue; 239 continue;
240 } 240 }
241 else 241 else
@@ -248,14 +248,14 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X @@ -248,14 +248,14 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X
248 tinyxml2::XMLNode *pChild = pNode->FirstChild(); 248 tinyxml2::XMLNode *pChild = pNode->FirstChild();
249 if( pChild == NULL ) 249 if( pChild == NULL )
250 { 250 {
251 - LOG_DEBUG( "����ֵû������" ); 251 + LOG_DEBUG( "参数值没有设置" );
252 continue; 252 continue;
253 } 253 }
254 254
255 const char *value = pChild->Value(); 255 const char *value = pChild->Value();
256 if( value == NULL ) 256 if( value == NULL )
257 { 257 {
258 - LOG_DEBUG( "����ֵΪ��" ); 258 + LOG_DEBUG( "参数值为空" );
259 continue; 259 continue;
260 } 260 }
261 else 261 else
@@ -270,7 +270,7 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X @@ -270,7 +270,7 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X
270 const char *type = pItem->Value(); 270 const char *type = pItem->Value();
271 if( type == NULL ) 271 if( type == NULL )
272 { 272 {
273 - LOG_DEBUG( "��������Ϊ��" ); 273 + LOG_DEBUG( "参数名字为空" );
274 continue; 274 continue;
275 } 275 }
276 276
@@ -280,19 +280,19 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X @@ -280,19 +280,19 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X
280 } 280 }
281 else 281 else
282 { 282 {
283 - LOG_DEBUG( "����δ����IJ���:{}" , type ); 283 + LOG_DEBUG( "国标未定义的参数:{}" , type );
284 continue; 284 continue;
285 } 285 }
286 } 286 }
287 } 287 }
288 else 288 else
289 { 289 {
290 - LOG_DEBUG( "����δ����IJ���:{}" , type ); 290 + LOG_DEBUG( "国标未定义的参数:{}" , type );
291 continue; 291 continue;
292 } 292 }
293 } 293 }
294 294
295 - // Ŀ¼�� 295 + // 目录项
296 std::list< tinyxml2::XMLNode* >::iterator it = items.begin(); 296 std::list< tinyxml2::XMLNode* >::iterator it = items.begin();
297 std::list< tinyxml2::XMLNode* >::iterator end = items.end(); 297 std::list< tinyxml2::XMLNode* >::iterator end = items.end();
298 for( /*it*/; it != end; ++it ) 298 for( /*it*/; it != end; ++it )
@@ -303,21 +303,21 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X @@ -303,21 +303,21 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X
303 const char *type = pItem->Value(); 303 const char *type = pItem->Value();
304 if( type == NULL ) 304 if( type == NULL )
305 { 305 {
306 - LOG_DEBUG( "��������Ϊ��" ); 306 + LOG_DEBUG( "参数名字为空" );
307 continue; 307 continue;
308 } 308 }
309 309
310 tinyxml2::XMLNode *pValue = pItem->FirstChild(); 310 tinyxml2::XMLNode *pValue = pItem->FirstChild();
311 if( pValue == NULL ) 311 if( pValue == NULL )
312 { 312 {
313 - LOG_DEBUG( "����ֵû������" ); 313 + LOG_DEBUG( "参数值没有设置" );
314 continue; 314 continue;
315 } 315 }
316 316
317 const char *value = pValue->Value(); 317 const char *value = pValue->Value();
318 if( value == NULL ) 318 if( value == NULL )
319 { 319 {
320 - LOG_DEBUG( "����ֵΪ��" ); 320 + LOG_DEBUG( "参数值为空" );
321 continue; 321 continue;
322 } 322 }
323 323
@@ -357,7 +357,7 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X @@ -357,7 +357,7 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X
357 } 357 }
358 else 358 else
359 { 359 {
360 - LOG_ERROR( "Event����ֵ\'{}\'��Ч", value ); 360 + LOG_ERROR( "Event参数值\'{}\'无效", value );
361 return cat_list; 361 return cat_list;
362 } 362 }
363 } 363 }
@@ -488,21 +488,21 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X @@ -488,21 +488,21 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X
488 pValue = pInfo->FirstChild(); 488 pValue = pInfo->FirstChild();
489 if( pValue == NULL ) 489 if( pValue == NULL )
490 { 490 {
491 - LOG_DEBUG( "����ֵû������" ); 491 + LOG_DEBUG( "参数值没有设置" );
492 continue; 492 continue;
493 } 493 }
494 494
495 const char *type = pInfo->Value(); 495 const char *type = pInfo->Value();
496 if( type == NULL ) 496 if( type == NULL )
497 { 497 {
498 - LOG_DEBUG( "��������Ϊ��" ); 498 + LOG_DEBUG( "参数名字为空" );
499 continue; 499 continue;
500 } 500 }
501 501
502 const char *value = pValue->Value(); 502 const char *value = pValue->Value();
503 if( value == NULL ) 503 if( value == NULL )
504 { 504 {
505 - LOG_DEBUG( "����ֵΪ��" ); 505 + LOG_DEBUG( "参数值为空" );
506 continue; 506 continue;
507 } 507 }
508 508
@@ -540,13 +540,13 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X @@ -540,13 +540,13 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode( const std::vector&lt; tinyxml2::X
540 } 540 }
541 else 541 else
542 { 542 {
543 - LOG_DEBUG( "����δ����IJ���:{}" , type ); 543 + LOG_DEBUG( "国标未定义的参数:{}" , type );
544 } 544 }
545 } 545 }
546 } 546 }
547 else 547 else
548 { 548 {
549 - LOG_DEBUG( "����δ����IJ���:{}" , type ); 549 + LOG_DEBUG( "国标未定义的参数:{}" , type );
550 } 550 }
551 } 551 }
552 552
@@ -622,10 +622,9 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode_Catlog(const char* body) @@ -622,10 +622,9 @@ std::vector&lt; DeviceInfo &gt; CCatalogParser::Decode_Catlog(const char* body)
622 cat_list = Decode(nodes); 622 cat_list = Decode(nodes);
623 if (cat_list.empty()) 623 if (cat_list.empty())
624 { 624 {
625 - LOG_ERROR("��Ϣ���������!"); 625 + LOG_ERROR("消息体解析错误!");
626 } 626 }
627 } 627 }
628 628
629 -  
630 return cat_list; 629 return cat_list;
631 } 630 }
632 \ No newline at end of file 631 \ No newline at end of file