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
cebc4722
Commit
cebc4722
authored
4 years ago
by
Steven Murray
Browse files
Options
Downloads
Plain Diff
Merge branch 'gcd-stdout-logging'
parents
ea9a2eef
b6e90643
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
python/eosfstgcd/cta-fst-gcd.1cta
+5
-2
5 additions, 2 deletions
python/eosfstgcd/cta-fst-gcd.1cta
python/eosfstgcd/ctafstgcd.py
+16
-6
16 additions, 6 deletions
python/eosfstgcd/ctafstgcd.py
with
21 additions
and
8 deletions
python/eosfstgcd/cta-fst-gcd.1cta
+
5
−
2
View file @
cebc4722
...
...
@@ -43,6 +43,9 @@ Prints the usage message.
\fB\-c CONFIG, \-\-config CONFIG
Sets the path of the configuration file. If not set then the default value of
\fB/etc/cta/cta-fst-gcd.conf\fP is used.
.TP
\fB\-s, \-\-stdout
Sets log output to stdout. This disables use of a log file.
.SH RETURN VALUE
Zero on success and non-zero on failure.
.SH FILES
...
...
@@ -57,7 +60,7 @@ parameters.
.TP
.B /var/log/eos/fst/cta-fst-gcd.log
The default log file of the \fBcta-fst-gcd\fP daemon. This can be overriden by
modifying \fBcta-fst-gcd.conf\fP accordingly
.
modifying \fBcta-fst-gcd.conf\fP accordingly
or disabled using the
\fB\-s\fP/\fB\-\-stdout\fP option.
.SH AUTHOR
\fBCTA\fP Team
This diff is collapsed.
Click to expand it.
python/eosfstgcd/ctafstgcd.py
+
16
−
6
View file @
cebc4722
...
...
@@ -504,6 +504,7 @@ def main():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'
-c
'
,
'
--config
'
,
default
=
'
/etc/cta/{}.conf
'
.
format
(
programname
),
help
=
'
Configuration file path
'
)
parser
.
add_argument
(
'
-s
'
,
'
--stdout
'
,
action
=
'
store_true
'
,
help
=
'
Print logs to standard output, overriding configuration file path
'
)
args
=
parser
.
parse_args
()
if
not
os
.
path
.
isfile
(
args
.
config
):
...
...
@@ -521,7 +522,12 @@ def main():
hostname
=
socket
.
gethostname
()
fqdn
=
socket
.
getfqdn
()
log
=
get_logger
(
hostname
,
programname
,
config
.
log_file
)
if
args
.
stdout
==
True
:
# If --stdout has been given on the command line, use False as the log path to set output to stdout
log
=
get_logger
(
hostname
,
programname
,
False
)
else
:
log
=
get_logger
(
hostname
,
programname
,
config
.
log_file
)
log
.
info
(
'
{} started
'
.
format
(
programname
))
log
.
info
(
'
The fqdn of this machine is {}
'
.
format
(
fqdn
))
...
...
@@ -540,11 +546,15 @@ def get_logger(hostname, programname, logpath):
log_handler
=
None
logging_dir
=
os
.
path
.
dirname
(
logpath
)
if
not
os
.
path
.
isdir
(
logging_dir
):
raise
UserError
(
'
The logging directory {} is not a directory or does not exist
'
.
format
(
logging_dir
))
if
not
os
.
access
(
logging_dir
,
os
.
W_OK
):
raise
UserError
(
'
The logging directory {} cannot be written to
'
.
format
(
logging_dir
))
if
logpath
==
False
:
log_handler
=
logging
.
StreamHandler
(
stream
=
sys
.
stdout
)
else
:
logging_dir
=
os
.
path
.
dirname
(
logpath
)
if
not
os
.
path
.
isdir
(
logging_dir
):
raise
UserError
(
'
The logging directory {} is not a directory or does not exist
'
.
format
(
logging_dir
))
if
not
os
.
access
(
logging_dir
,
os
.
W_OK
):
raise
UserError
(
'
The logging directory {} cannot be written to
'
.
format
(
logging_dir
))
log_handler
=
logging
.
handlers
.
TimedRotatingFileHandler
(
filename
=
logpath
,
when
=
'
midnight
'
)
log_handler
=
logging
.
handlers
.
TimedRotatingFileHandler
(
filename
=
logpath
,
when
=
'
midnight
'
)
log_handler
.
setLevel
(
logging
.
INFO
)
...
...
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