Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
dCache
cta
Commits
4381e93d
Commit
4381e93d
authored
11 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
castor::log::LoggerImplementation now implements a log mask
parent
2c20bac7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
castor/log/LoggerImplementation.cpp
+54
-1
54 additions, 1 deletion
castor/log/LoggerImplementation.cpp
castor/log/LoggerImplementation.hpp
+24
-0
24 additions, 0 deletions
castor/log/LoggerImplementation.hpp
with
78 additions
and
1 deletion
castor/log/LoggerImplementation.cpp
+
54
−
1
View file @
4381e93d
...
...
@@ -48,7 +48,8 @@ castor::log::LoggerImplementation::LoggerImplementation(
m_maxMsgLen
(
determineMaxMsgLen
()),
m_logFile
(
-
1
),
m_connected
(
false
),
m_priorityToText
(
generatePriorityToTextMap
())
{
m_priorityToText
(
generatePriorityToTextMap
()),
m_configTextToPriority
(
generateConfigTextToPriorityMap
())
{
initMutex
();
}
...
...
@@ -122,6 +123,34 @@ std::map<int, std::string>
return
m
;
}
//------------------------------------------------------------------------------
// generateConfigTextToPriorityMap
//------------------------------------------------------------------------------
std
::
map
<
std
::
string
,
int
>
castor
::
log
::
LoggerImplementation
::
generateConfigTextToPriorityMap
()
const
throw
(
castor
::
exception
::
Internal
)
{
std
::
map
<
std
::
string
,
int
>
m
;
try
{
m
[
"LOG_EMERG"
]
=
LOG_EMERG
;
m
[
"LOG_ALERT"
]
=
LOG_ALERT
;
m
[
"LOG_CRIT"
]
=
LOG_CRIT
;
m
[
"LOG_ERR"
]
=
LOG_ERR
;
m
[
"LOG_WARNING"
]
=
LOG_WARNING
;
m
[
"LOG_NOTICE"
]
=
LOG_NOTICE
;
m
[
"LOG_INFO"
]
=
LOG_INFO
;
m
[
"LOG_DEBUG"
]
=
LOG_DEBUG
;
}
catch
(
std
::
exception
&
se
)
{
castor
::
exception
::
Internal
ex
;
ex
.
getMessage
()
<<
"Failed to generate configuration text to priority mapping: "
<<
se
.
what
();
throw
ex
;
}
return
m
;
}
//------------------------------------------------------------------------------
// initMutex
//------------------------------------------------------------------------------
...
...
@@ -465,3 +494,27 @@ void castor::log::LoggerImplementation::operator() (
Param
*
emptyParams
=
NULL
;
operator
()
(
priority
,
msg
,
0
,
emptyParams
);
}
//------------------------------------------------------------------------------
// logMask
//------------------------------------------------------------------------------
int
castor
::
log
::
LoggerImplementation
::
logMask
()
const
throw
()
{
const
char
*
const
p
=
getconfent
(
"LogMask"
,
m_programName
.
c_str
(),
0
);
// If the configuration file defines the log mask to use
if
(
p
!=
NULL
)
{
// Try to find the corresponding integer priority value
std
::
map
<
std
::
string
,
int
>::
const_iterator
itor
=
m_configTextToPriority
.
find
(
p
);
// Return the priority if it was found else return the default INFO level
if
(
m_configTextToPriority
.
end
()
!=
itor
)
{
return
itor
->
second
;
}
else
{
return
LOG_INFO
;
}
}
// If the priority wasn't found, default is INFO level
return
LOG_INFO
;
}
This diff is collapsed.
Click to expand it.
castor/log/LoggerImplementation.hpp
+
24
−
0
View file @
4381e93d
...
...
@@ -251,6 +251,17 @@ private:
*/
const
std
::
map
<
int
,
std
::
string
>
m_priorityToText
;
/**
* Map from the possible string values of the LogMask parameters of
* /etc/castor.conf and their equivalent syslog priorities.
*/
const
std
::
map
<
std
::
string
,
int
>
m_configTextToPriority
;
/**
* Returns the log mask for the program.
*/
int
logMask
()
const
throw
();
/**
* Determines the maximum message length that the client syslog server can
* handle.
...
...
@@ -267,6 +278,14 @@ private:
std
::
map
<
int
,
std
::
string
>
generatePriorityToTextMap
()
const
throw
(
castor
::
exception
::
Internal
);
/**
* Generates and returns the mapping between the possible string values
* of the LogMask parameters of /etc/castor.conf and their equivalent
* syslog priorities.
*/
std
::
map
<
std
::
string
,
int
>
generateConfigTextToPriorityMap
()
const
throw
(
castor
::
exception
::
Internal
);
/**
* Initializes the mutex used to protect the critical section of the
* LoggerImplementation object.
...
...
@@ -316,6 +335,11 @@ private:
// as we do when retrieving logs from the DB
//-------------------------------------------------------------------------
// Ignore messages whose priority is not of interest
if
(
priority
>
logMask
())
{
return
;
}
// Try to find the textual representation of the syslog priority
std
::
map
<
int
,
std
::
string
>::
const_iterator
priorityTextPair
=
m_priorityToText
.
find
(
priority
);
...
...
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