reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
SipXHelper.cxx
Go to the documentation of this file.
1
2#include <os/OsIntTypes.h>
3#include <os/OsSysLog.h>
4
5#include "rutil/Logger.hxx"
6
7#include "SipXHelper.hxx"
8
9#include "ReconSubsystem.hxx"
10
11#define RESIPROCATE_SUBSYSTEM ReconSubsystem::RECON
12
13using namespace resip;
14using namespace recon;
15
16//
17// There is one little annoyance with this: in the reSIProcate logs, the source file
18// and line number of the log entry will always be this file rather than the
19// name of the file in the sipXtapi source tree where the log message originated
20//
21void
22sipXlogHandler(const char* szPriority, const char* szSource, const char* szMsg)
23{
24 // we avoid parsing debug messages if not explicitly required to do so
25 if(szPriority[0] == 'D' && Log::level() < Log::Debug)
26 {
27 return;
28 }
29
30 // The log string from sipX includes all the different tags, we have to split them out again
31 UtlString date, eventCount, facility, priority, hostname, taskname, taskId, processId, content;
32 OsSysLog::parseLogString(szMsg, date, eventCount, facility, priority, hostname, taskname, taskId, processId, content);
33
34 switch(szPriority[0])
35 {
36 case 'D':
37 DebugLog(<< szSource << ":" << taskname << ":" << taskId << ": " << content);
38 break;
39 case 'I':
40 case 'N':
41 InfoLog(<< szSource << ":" << taskname << ":" << taskId << ": " << content);
42 break;
43 case 'W':
44 WarningLog(<< szSource << ":" << taskname << ":" << taskId << ": " << content);
45 break;
46 default:
47 ErrLog(<< szSource << ":" << taskname << ":" << taskId << ": " << content);
48 }
49}
50
51void
53{
54 OsSysLog::initialize(0, appName.c_str());
55 OsSysLog::setCallbackFunction(sipXlogHandler);
56 // Enable all logging types, it will be filtered by the reSIProcate logger
57 OsSysLog::setLoggingPriority(PRI_DEBUG);
58}
59
60//
61// There is one little annoyance with this: in the reSIProcate logs, the source file
62// and line number of the log entry will always be this file rather than the
63// name of the file in the sipXtapi source tree where the log message originated
64//
65bool
66sipXPreQueueLogHandler(const char* szPriority, const char* szMsg, unsigned int taskId)
67{
68 // Note: this executes in the thread that performed the log, so we will let the resip logger
69 // add the threadId to the log message, so we don't need to do anything with taskId passed in
70 switch (szPriority[0])
71 {
72 case 'D':
73 DebugLog(<< szMsg);
74 break;
75 case 'I':
76 case 'N':
77 InfoLog(<< szMsg);
78 break;
79 case 'W':
80 WarningLog(<< szMsg);
81 break;
82 default:
83 ErrLog(<< szMsg);
84 }
85 return false; // No furher sipX processing needed
86}
87
88void
90{
91 OsSysLog::initialize(0, appName.c_str());
92#ifndef SIPX_NO_RECORD // FIXME the line below requires latest sipXtapi code
93 OsSysLog::setPreQueueCallbackFunction(sipXPreQueueLogHandler);
94#endif
95 // Enable all logging types, it will be filtered by the reSIProcate logger,
96 // application can reset to some other level if this is not desired.
97 OsSysLog::setLoggingPriority(PRI_DEBUG);
98}
99
100/* ====================================================================
101 *
102 * Copyright 2022 SIP Spectrum, Inc. http://sipspectrum.com
103 * Copyright 2014 Daniel Pocock http://danielpocock.com
104 * All rights reserved.
105 *
106 * Redistribution and use in source and binary forms, with or without
107 * modification, are permitted provided that the following conditions
108 * are met:
109 *
110 * 1. Redistributions of source code must retain the above copyright
111 * notice, this list of conditions and the following disclaimer.
112 *
113 * 2. Redistributions in binary form must reproduce the above copyright
114 * notice, this list of conditions and the following disclaimer in
115 * the documentation and/or other materials provided with the
116 * distribution.
117 *
118 * 3. Neither the name of the author(s) nor the names of any contributors
119 * may be used to endorse or promote products derived from this software
120 * without specific prior written permission.
121 *
122 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
123 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
124 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
125 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
126 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
127 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
128 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
129 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
130 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
132 * SUCH DAMAGE.
133 *
134 * ====================================================================
135 *
136 *
137 */
138
#define DebugLog(args_)
Definition Logger.hxx:128
#define InfoLog(args_)
Definition Logger.hxx:131
#define WarningLog(args_)
Definition Logger.hxx:134
#define ErrLog(args_)
Definition Logger.hxx:137
void sipXlogHandler(const char *szPriority, const char *szSource, const char *szMsg)
bool sipXPreQueueLogHandler(const char *szPriority, const char *szMsg, unsigned int taskId)
static void setupPreQueueLoggingBridge(const resip::Data &appName)
static void setupLoggingBridge(const resip::Data &appName)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
const char * c_str() const
Returns a null-terminated string representing.
Definition Data.cxx:1097
static Level level()
Return logging level for current thread.
Definition Log.hxx:221
@ Debug
Definition Log.hxx:84
dcm! – add UnusedChecking(_enum) below;