Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
07687a2d
Commit
07687a2d
authored
6 years ago
by
Peterson, Peter
Browse files
Options
Downloads
Patches
Plain Diff
Warn user and ignore *FilterChannel properties
This will allow users to have logging again
parent
994efd76
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Framework/Kernel/src/ConfigService.cpp
+45
-0
45 additions, 0 deletions
Framework/Kernel/src/ConfigService.cpp
Framework/Kernel/test/ConfigServiceTest.h
+4
-2
4 additions, 2 deletions
Framework/Kernel/test/ConfigServiceTest.h
with
49 additions
and
2 deletions
Framework/Kernel/src/ConfigService.cpp
+
45
−
0
View file @
07687a2d
...
@@ -325,6 +325,48 @@ void ConfigServiceImpl::setBaseDirectory() {
...
@@ -325,6 +325,48 @@ void ConfigServiceImpl::setBaseDirectory() {
#endif
#endif
}
}
namespace
{
// look for specific keys and throw an exception if one is found
std
::
string
checkForBadConfigOptions
(
const
std
::
string
&
filename
,
const
std
::
string
&
propertiesString
)
{
std
::
stringstream
stream
(
propertiesString
);
std
::
stringstream
resultPropertiesString
;
std
::
string
line
;
int
line_num
=
0
;
while
(
std
::
getline
(
stream
,
line
))
{
line_num
+=
1
;
// increment early
bool
is_ok
=
true
;
// Check for common errors. Empty lines are ok, things that are a key
// without a value are a critical failure. Forbidden keys are just commented
// out.
if
(
line
.
empty
()
||
(
Kernel
::
Strings
::
strip
(
line
)[
0
]
==
'#'
))
{
// do nothing
}
else
if
(
line
.
find
(
"FilterChannel"
)
!=
std
::
string
::
npos
)
{
is_ok
=
false
;
}
// Print warning to error channel and comment out offending line
if
(
!
is_ok
)
{
const
auto
end
=
line
.
find
(
"="
);
std
::
cerr
<<
"Encontered invalid key
\"
"
;
if
(
end
!=
std
::
string
::
npos
)
{
std
::
cerr
<<
Kernel
::
Strings
::
strip
(
line
.
substr
(
0
,
end
));
}
else
{
std
::
cerr
<<
Kernel
::
Strings
::
strip
(
line
);
}
std
::
cerr
<<
"
\"
in "
<<
filename
<<
" on line "
<<
line_num
<<
std
::
endl
;
// comment out the property
resultPropertiesString
<<
'#'
;
}
// copy over the line
resultPropertiesString
<<
line
<<
'\n'
;
}
return
resultPropertiesString
.
str
();
}
}
// end of anonymous namespace
/** Loads the config file provided.
/** Loads the config file provided.
* If the file contains logging setup instructions then these will be used to
* If the file contains logging setup instructions then these will be used to
*setup the logging framework.
*setup the logging framework.
...
@@ -358,6 +400,9 @@ void ConfigServiceImpl::loadConfig(const std::string &filename,
...
@@ -358,6 +400,9 @@ void ConfigServiceImpl::loadConfig(const std::string &filename,
}
}
}
}
// verify the contents and comment out offending lines
temp
=
checkForBadConfigOptions
(
filename
,
temp
);
// store the property string
// store the property string
if
((
append
)
&&
(
!
m_PropertyString
.
empty
()))
{
if
((
append
)
&&
(
!
m_PropertyString
.
empty
()))
{
m_PropertyString
=
m_PropertyString
+
"
\n
"
+
temp
;
m_PropertyString
=
m_PropertyString
+
"
\n
"
+
temp
;
...
...
This diff is collapsed.
Click to expand it.
Framework/Kernel/test/ConfigServiceTest.h
+
4
−
2
View file @
07687a2d
...
@@ -483,6 +483,7 @@ public:
...
@@ -483,6 +483,7 @@ public:
writer
<<
"
\n
"
;
writer
<<
"
\n
"
;
writer
<<
"mantid.thorax = 10
\n
"
;
writer
<<
"mantid.thorax = 10
\n
"
;
writer
<<
"# This comment line
\n
"
;
writer
<<
"# This comment line
\n
"
;
writer
<<
" # This is an indented comment line
\n
"
;
writer
<<
"key.withnospace=5
\n
"
;
writer
<<
"key.withnospace=5
\n
"
;
writer
<<
"key.withnovalue"
;
writer
<<
"key.withnovalue"
;
writer
.
close
();
writer
.
close
();
...
@@ -512,11 +513,12 @@ public:
...
@@ -512,11 +513,12 @@ public:
}
}
reader
.
close
();
reader
.
close
();
TS_ASSERT_EQUALS
(
prop_lines
.
size
(),
4
);
TS_ASSERT_EQUALS
(
prop_lines
.
size
(),
5
);
TS_ASSERT_EQUALS
(
prop_lines
[
0
],
"mantid.legs=6"
);
TS_ASSERT_EQUALS
(
prop_lines
[
0
],
"mantid.legs=6"
);
TS_ASSERT_EQUALS
(
prop_lines
[
1
],
""
);
TS_ASSERT_EQUALS
(
prop_lines
[
1
],
""
);
TS_ASSERT_EQUALS
(
prop_lines
[
2
],
"# This comment line"
);
TS_ASSERT_EQUALS
(
prop_lines
[
2
],
"# This comment line"
);
TS_ASSERT_EQUALS
(
prop_lines
[
3
],
"key.withnospace=5"
);
TS_ASSERT_EQUALS
(
prop_lines
[
3
],
" # This is an indented comment line"
);
TS_ASSERT_EQUALS
(
prop_lines
[
4
],
"key.withnospace=5"
);
// Clean up
// Clean up
prop_file
.
remove
();
prop_file
.
remove
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment