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
517f0dcc
Commit
517f0dcc
authored
9 years ago
by
Eric Cano
Browse files
Options
Downloads
Patches
Plain Diff
Added support for logging to stdout in cta-taped.
parent
a595be58
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tapeserver/cta-taped.cpp
+75
-34
75 additions, 34 deletions
tapeserver/cta-taped.cpp
with
75 additions
and
34 deletions
tapeserver/cta-taped.cpp
+
75
−
34
View file @
517f0dcc
...
...
@@ -17,8 +17,10 @@
*/
#include
"common/Configuration.hpp"
#include
"common/log/StdoutLogger.hpp"
#include
"common/log/SyslogLogger.hpp"
#include
"common/processCap/ProcessCap.hpp"
#include
"tapeserver/daemon/CommandLineParams.hpp"
#include
"tapeserver/daemon/GlobalConfiguration.hpp"
#include
"tapeserver/daemon/TpconfigLines.hpp"
#include
"tapeserver/daemon/TapeDaemon.hpp"
...
...
@@ -31,6 +33,8 @@
#include
<string>
#include
<iostream>
namespace
cta
{
namespace
taped
{
//------------------------------------------------------------------------------
// exceptionThrowingMain
//
...
...
@@ -45,41 +49,19 @@ static int exceptionThrowingMain(const int argc, char **const argv,
cta
::
log
::
Logger
&
log
);
//------------------------------------------------------------------------------
//
ma
in
//
The help str
in
g
//------------------------------------------------------------------------------
int
main
(
const
int
argc
,
char
**
const
argv
)
{
using
namespace
cta
;
// Try to instantiate the logging system API
std
::
unique_ptr
<
log
::
SyslogLogger
>
logPtr
;
try
{
logPtr
.
reset
(
new
log
::
SyslogLogger
(
log
::
SOCKET_NAME
,
"cta-taped"
,
log
::
DEBUG
));
}
catch
(
exception
::
Exception
&
ex
)
{
std
::
cerr
<<
"Failed to instantiate object representing CTA logging system: "
<<
ex
.
getMessage
().
str
()
<<
std
::
endl
;
return
1
;
}
log
::
Logger
&
log
=
*
logPtr
;
int
programRc
=
EXIT_FAILURE
;
// Default return code when receiving an exception.
try
{
programRc
=
exceptionThrowingMain
(
argc
,
argv
,
log
);
}
catch
(
exception
::
Exception
&
ex
)
{
std
::
list
<
log
::
Param
>
params
=
{
log
::
Param
(
"message"
,
ex
.
getMessage
().
str
())};
log
(
log
::
ERR
,
"Caught an unexpected CTA exception"
,
params
);
}
catch
(
std
::
exception
&
se
)
{
std
::
list
<
log
::
Param
>
params
=
{
log
::
Param
(
"what"
,
se
.
what
())};
log
(
log
::
ERR
,
"Caught an unexpected standard exception"
,
params
);
}
catch
(...)
{
log
(
log
::
ERR
,
"Caught an unexpected and unknown exception"
);
}
google
::
protobuf
::
ShutdownProtobufLibrary
();
return
programRc
;
}
std
::
string
gHelpString
=
"Usage: cta-taped [options]
\n
"
"
\n
"
"where options can be:
\n
"
"
\n
"
"
\t
--foreground or -f
\t
Remain in the Foreground
\n
"
"
\t
--stdout or -s
\t
Print logs to standard output. Required --foreground
\n
"
"
\t
--config <config-file> or -c
\t
Configuration file
\n
"
"
\t
--help or -h
\t
Print this help and exit
\n
"
"
\n
"
"Comments to: Castor.Support@cern.ch
\n
"
;
//------------------------------------------------------------------------------
// Logs the start of the daemon.
...
...
@@ -199,3 +181,62 @@ static std::string argvToString(const int argc, const char *const *const argv) {
// cta::log::Param("librarySlot", line.librarySlot)};
// log(log::INFO, "TPCONFIG line", params);
//}
}}
// namespace cta::taped
//------------------------------------------------------------------------------
// main
//------------------------------------------------------------------------------
int
main
(
const
int
argc
,
char
**
const
argv
)
{
using
namespace
cta
;
// Interpret the command line
std
::
unique_ptr
<
cta
::
daemon
::
CommandLineParams
>
commandLine
;
try
{
commandLine
.
reset
(
new
cta
::
daemon
::
CommandLineParams
(
argc
,
argv
));
}
catch
(
exception
::
Exception
&
ex
)
{
std
::
cerr
<<
"Failed to interpret the command line parameters: "
<<
ex
.
getMessage
().
str
()
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
if
(
commandLine
->
helpRequested
)
{
std
::
cout
<<
cta
::
taped
::
gHelpString
<<
std
::
endl
;
return
EXIT_SUCCESS
;
}
// Try to instantiate the logging system API
std
::
unique_ptr
<
log
::
Logger
>
logPtr
;
try
{
if
(
commandLine
->
logToStdout
)
{
logPtr
.
reset
(
new
log
::
StdoutLogger
(
"cta-taped"
));
}
else
{
logPtr
.
reset
(
new
log
::
SyslogLogger
(
log
::
SOCKET_NAME
,
"cta-taped"
,
log
::
DEBUG
));
}
}
catch
(
exception
::
Exception
&
ex
)
{
std
::
cerr
<<
"Failed to instantiate object representing CTA logging system: "
<<
ex
.
getMessage
().
str
()
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
log
::
Logger
&
log
=
*
logPtr
;
int
programRc
=
EXIT_FAILURE
;
// Default return code when receiving an exception.
try
{
programRc
=
cta
::
taped
::
exceptionThrowingMain
(
argc
,
argv
,
log
);
}
catch
(
exception
::
Exception
&
ex
)
{
std
::
list
<
log
::
Param
>
params
=
{
log
::
Param
(
"message"
,
ex
.
getMessage
().
str
())};
log
(
log
::
ERR
,
"Caught an unexpected CTA exception"
,
params
);
}
catch
(
std
::
exception
&
se
)
{
std
::
list
<
log
::
Param
>
params
=
{
log
::
Param
(
"what"
,
se
.
what
())};
log
(
log
::
ERR
,
"Caught an unexpected standard exception"
,
params
);
}
catch
(...)
{
log
(
log
::
ERR
,
"Caught an unexpected and unknown exception"
);
}
google
::
protobuf
::
ShutdownProtobufLibrary
();
return
programRc
;
}
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