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
bf0bf9ac
Commit
bf0bf9ac
authored
8 years ago
by
Eric Cano
Browse files
Options
Downloads
Patches
Plain Diff
Added -l option to taped so logs go to a file.
parent
ffb053fb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tapeserver/cta-taped.cpp
+8
-4
8 additions, 4 deletions
tapeserver/cta-taped.cpp
tapeserver/daemon/CommandLineParams.cpp
+21
-7
21 additions, 7 deletions
tapeserver/daemon/CommandLineParams.cpp
tapeserver/daemon/CommandLineParams.hpp
+2
-0
2 additions, 0 deletions
tapeserver/daemon/CommandLineParams.hpp
with
31 additions
and
11 deletions
tapeserver/cta-taped.cpp
+
8
−
4
View file @
bf0bf9ac
...
...
@@ -17,6 +17,7 @@
*/
#include
"common/Configuration.hpp"
#include
"common/log/FileLogger.hpp"
#include
"common/log/StdoutLogger.hpp"
#include
"common/log/SyslogLogger.hpp"
#include
"common/processCap/ProcessCap.hpp"
...
...
@@ -56,10 +57,11 @@ std::string gHelpString =
"
\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
"
"
\t
--foreground or -f
\t
Remain in the Foreground
\n
"
"
\t
--stdout or -s
\t
Print logs to standard output. Required --foreground
\n
"
"
\t
--log-to-file <log-file> or -l
\t
Logs to a given file (instead of default syslog)
\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
"
;
...
...
@@ -214,6 +216,8 @@ int main(const int argc, char **const argv) {
try
{
if
(
commandLine
->
logToStdout
)
{
logPtr
.
reset
(
new
log
::
StdoutLogger
(
"cta-taped"
));
}
else
if
(
commandLine
->
logToFile
)
{
logPtr
.
reset
(
new
log
::
FileLogger
(
"cta-taped"
,
commandLine
->
logFilePath
,
log
::
DEBUG
));
}
else
{
logPtr
.
reset
(
new
log
::
SyslogLogger
(
"cta-taped"
,
log
::
DEBUG
));
}
...
...
This diff is collapsed.
Click to expand it.
tapeserver/daemon/CommandLineParams.cpp
+
21
−
7
View file @
bf0bf9ac
...
...
@@ -24,10 +24,10 @@
namespace
cta
{
namespace
daemon
{
CommandLineParams
::
CommandLineParams
(
int
argc
,
char
**
argv
)
:
foreground
(
false
),
logToStdout
(
false
),
foreground
(
false
),
logToStdout
(
false
),
logToFile
(
false
),
configFileLocation
(
"/etc/cta/cta.conf"
),
helpRequested
(
false
){
struct
::
option
longopts
[
5
];
struct
::
option
longopts
[
6
];
longopts
[
0
].
name
=
"foreground"
;
longopts
[
0
].
has_arg
=
no_argument
;
...
...
@@ -49,6 +49,11 @@ CommandLineParams::CommandLineParams(int argc, char** argv):
longopts
[
3
].
flag
=
NULL
;
longopts
[
3
].
val
=
's'
;
longopts
[
4
].
name
=
"log-to-file"
;
longopts
[
3
].
has_arg
=
required_argument
;
longopts
[
3
].
flag
=
NULL
;
longopts
[
3
].
val
=
'l'
;
memset
(
&
longopts
[
4
],
0
,
sizeof
(
struct
::
option
));
char
c
;
...
...
@@ -57,7 +62,7 @@ CommandLineParams::CommandLineParams(int argc, char** argv):
// Prevent getopt from printing out errors on stdout
opterr
=
0
;
// We ask getopt to not reshuffle argv ('+')
while
((
c
=
getopt_long
(
argc
,
argv
,
"+fsc:h"
,
longopts
,
NULL
))
!=
-
1
)
{
while
((
c
=
getopt_long
(
argc
,
argv
,
"+fsc:
l:
h"
,
longopts
,
NULL
))
!=
-
1
)
{
switch
(
c
)
{
case
'f'
:
foreground
=
true
;
...
...
@@ -71,6 +76,10 @@ CommandLineParams::CommandLineParams(int argc, char** argv):
case
'h'
:
helpRequested
=
true
;
break
;
case
'l'
:
logFilePath
=
optarg
;
logToFile
=
true
;
break
;
default:
break
;
}
...
...
@@ -78,14 +87,19 @@ CommandLineParams::CommandLineParams(int argc, char** argv):
if
(
logToStdout
&&
!
foreground
)
{
throw
cta
::
exception
::
Exception
(
"In CommandLineParams::CommandLineParams(): cannot log to stdout without running in the foreground"
);
}
if
(
logToFile
&&
logToStdout
)
{
throw
cta
::
exception
::
Exception
(
"In CommandLineParams::CommandLineParams(): cannot log to both stdout and file"
);
}
}
std
::
list
<
cta
::
log
::
Param
>
CommandLineParams
::
toLogParams
()
const
{
std
::
list
<
cta
::
log
::
Param
>
ret
;
ret
.
push_back
(
cta
::
log
::
Param
(
"foreground"
,
foreground
));
ret
.
push_back
(
cta
::
log
::
Param
(
"logToStdout"
,
logToStdout
));
ret
.
push_back
(
cta
::
log
::
Param
(
"configFileLocation"
,
configFileLocation
));
ret
.
push_back
(
cta
::
log
::
Param
(
"helpRequested"
,
helpRequested
));
ret
.
push_back
({
"foreground"
,
foreground
});
ret
.
push_back
({
"logToStdout"
,
logToStdout
});
ret
.
push_back
({
"logToFile"
,
logToFile
});
ret
.
push_back
({
"logFilePath"
,
logFilePath
});
ret
.
push_back
({
"configFileLocation"
,
configFileLocation
});
ret
.
push_back
({
"helpRequested"
,
helpRequested
});
return
ret
;
}
...
...
This diff is collapsed.
Click to expand it.
tapeserver/daemon/CommandLineParams.hpp
+
2
−
0
View file @
bf0bf9ac
...
...
@@ -33,6 +33,8 @@ struct CommandLineParams{
CommandLineParams
(
int
argc
,
char
**
argv
);
bool
foreground
;
///< Prevents daemonisation
bool
logToStdout
;
///< Log to stdout instead of syslog. Foreground is required.
bool
logToFile
;
///< Log to file intead of syslog.
std
::
string
logFilePath
;
std
::
string
configFileLocation
;
///< Location of the configuration file. Defaults to /etc/cta/cta.conf
bool
helpRequested
;
///< Help requested: will print out help and exit.
std
::
list
<
cta
::
log
::
Param
>
toLogParams
()
const
;
///< Convert the command line into set of parameters for logging.
...
...
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