Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
portabledsb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
External Wiki
External Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
App_Technologies
portabledsb
Commits
a00176c0
Commit
a00176c0
authored
Dec 30, 2015
by
jacobgladish
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added libxml logger
Without this, libxml errors go to stdout.
parent
470e483e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
1 deletion
+50
-1
Bridge/BridgeConfig.cpp
Bridge/BridgeConfig.cpp
+50
-1
No files found.
Bridge/BridgeConfig.cpp
View file @
a00176c0
...
...
@@ -9,12 +9,60 @@
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <libxml/xmlerror.h>
#include <libxml/xmlsave.h>
namespace
{
DSB_DECLARE_LOGNAME
(
BridgeConfig
);
void
libXmlGenericErrorFunc
(
void
*
/*ctx*/
,
xmlErrorPtr
error
)
{
if
(
!
error
)
return
;
common
::
Logger
::
Level
level
=
common
::
Logger
::
DSB_LOGLEVEL_INFO
;
switch
(
error
->
level
)
{
case
XML_ERR_NONE
:
level
=
common
::
Logger
::
DSB_LOGLEVEL_DEBUG
;
break
;
case
XML_ERR_WARNING
:
level
=
common
::
Logger
::
DSB_LOGLEVEL_WARN
;
break
;
case
XML_ERR_ERROR
:
level
=
common
::
Logger
::
DSB_LOGLEVEL_ERROR
;
break
;
case
XML_ERR_FATAL
:
level
=
common
::
Logger
::
DSB_LOGLEVEL_FATAL
;
break
;
}
// remove newline. I hate blank lines in logfiles.
if
(
error
->
message
)
{
char
*
p
=
strrchr
(
error
->
message
,
'\n'
);
if
(
p
)
*
p
=
'\0'
;
}
char
const
*
msg
=
error
->
message
;
if
(
!
msg
)
msg
=
"<unknown error>"
;
common
::
Logger
::
Write
(
__dsb_logger_module_name__
,
level
,
__FILE__
,
__LINE__
,
"libxml: %s"
,
msg
);
}
void
installXmlLogger
()
{
static
bool
libXmlLoggerInstalled
=
false
;
if
(
!
libXmlLoggerInstalled
)
{
xmlSetStructuredErrorFunc
(
NULL
,
&
libXmlGenericErrorFunc
);
libXmlLoggerInstalled
=
true
;
}
}
inline
xmlChar
const
*
toXmlChar
(
char
const
*
s
)
{
return
reinterpret_cast
<
xmlChar
const
*>
(
s
);
...
...
@@ -110,6 +158,7 @@ namespace
bridge
::
BridgeConfig
::
BridgeConfig
()
:
m_doc
(
NULL
)
{
installXmlLogger
();
}
bridge
::
BridgeConfig
::~
BridgeConfig
()
...
...
@@ -124,7 +173,7 @@ bridge::BridgeConfig::FromFile(std::string const& fileName)
QStatus
st
=
ER_OK
;
m_fileName
=
fileName
;
installXmlLogger
();
xmlInitParser
();
xmlDocPtr
doc
=
xmlParseFile
(
m_fileName
.
c_str
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment