Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl
Commits
06d2602f
Commit
06d2602f
authored
12 years ago
by
Steve Trevanion
Browse files
Options
Downloads
Patches
Plain Diff
can add date to logfile name if you wish (using init_log_date)
parent
9de2062c
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
modules/Bio/EnsEMBL/Utils/ConversionSupport.pm
+40
-9
40 additions, 9 deletions
modules/Bio/EnsEMBL/Utils/ConversionSupport.pm
with
40 additions
and
9 deletions
modules/Bio/EnsEMBL/Utils/ConversionSupport.pm
+
40
−
9
View file @
06d2602f
...
...
@@ -98,7 +98,7 @@ sub new {
Description : This method reads options from a configuration file and parses
some commandline options that are common to all scripts (like
db connection settings, help, dry-run). Commandline options
will override config file settings.
will override config file settings.
All options will be accessible via $self->param('name').
Return type : true on success
...
...
@@ -164,7 +164,6 @@ sub parse_common_options {
# override configured parameter with commandline options
map
{
$self
->
param
(
$_
,
$h
{
$_
})
}
keys
%h
;
return
(
1
)
if
$self
->
param
('
nolog
');
# if logpath & logfile are not set, set them here to /ensemblweb/vega_dev/shared/logs/conversion/DBNAME/SCRIPNAME_NN.log
...
...
@@ -173,7 +172,7 @@ sub parse_common_options {
}
my
$dbname
=
$self
->
param
('
dbname
');
$dbname
=~
s/^vega_//
;
if
(
not
(
defined
(
$self
->
param
('
logpath
')))){
if
(
not
(
defined
(
$self
->
param
('
logpath
'))
)){
$self
->
param
('
logpath
',
$self
->
param
('
log_base_path
')
.
"
/
"
.
$dbname
.
"
/
"
);
}
if
(
not
defined
$self
->
param
('
logfile
')
){
...
...
@@ -181,7 +180,7 @@ sub parse_common_options {
$log
=~
s/.pl$//g
;
my
$counter
;
for
(
$counter
=
1
;
(
-
e
$self
->
param
('
logpath
')
.
"
/
"
.
$log
.
"
_
"
.
sprintf
("
%03d
",
$counter
)
.
"
.log
");
$counter
++
){
#
warn $self->param('logpath')."/".$log."_".$counter.".log";
#
warn $self->param('logpath')."/".$log."_".$counter.".log";
}
$self
->
param
('
logfile
',
$log
.
"
_
"
.
sprintf
("
%03d
",
$counter
)
.
"
.log
");
}
...
...
@@ -1216,7 +1215,7 @@ sub lock_log {
Description : Unlock log previously locked by lock_log.
=cut
=cut
sub
unlock_log
{
my
(
$self
)
=
@_
;
...
...
@@ -1336,11 +1335,12 @@ sub log_stamped {
=cut
sub
log_filehandle
{
my
(
$self
,
$mode
)
=
@_
;
my
(
$self
,
$mode
,
$date
)
=
@_
;
$mode
||=
'
>
';
$mode
=
'
>>
'
if
(
$self
->
param
('
logappend
'));
my
$fh
=
\
*STDERR
;
if
(
my
$logfile
=
$self
->
param
('
logfile
'))
{
$logfile
.=
"
_
$date
"
if
$date
;
if
(
my
$logpath
=
$self
->
param
('
logpath
'))
{
unless
(
-
e
$logpath
)
{
system
("
mkdir
$logpath
")
==
0
or
...
...
@@ -1385,6 +1385,22 @@ sub filehandle {
return
$fh
;
}
=head2 init_log_date
Example : $support->init_log_date;
Description : Opens a filehandle to a logfile with the date in the file name
Return type : Filehandle - the log filehandle
Exceptions : none
Caller : general
=cut
sub
init_log_date
{
my
$self
=
shift
;
my
$date
=
$self
->
date
;
return
$self
->
init_log
(
$date
);
}
=head2 init_log
Example : $support->init_log;
...
...
@@ -1400,9 +1416,10 @@ sub filehandle {
sub
init_log
{
my
$self
=
shift
;
my
$date
=
shift
;
# get a log filehandle
my
$log
=
$self
->
log_filehandle
;
my
$log
=
$self
->
log_filehandle
(
undef
,
$date
)
;
# print script name, date, user who is running it
my
$hostname
=
`
hostname
`;
...
...
@@ -1410,7 +1427,7 @@ sub init_log {
my
$script
=
"
$hostname
:
$Bin
/
$Script
";
my
$user
=
`
whoami
`;
chomp
$user
;
$self
->
log
("
Script:
$script
\n
Date:
"
.
$self
->
date
.
"
\n
User:
$user
\n
");
$self
->
log
("
Script:
$script
\n
Date:
"
.
$self
->
date
_and_time
.
"
\n
User:
$user
\n
");
# print parameters the script is running with
$self
->
log
("
Parameters:
\n\n
");
...
...
@@ -1469,7 +1486,7 @@ sub date_and_mem {
=head2 date
Example : print "Date: " . $support->date . "\n";
Description : Prints a nicely formatted
times
tamp (YYYY-DD-MM
hh:mm:ss
)
Description : Prints a nicely formatted
date
tamp (YYYY-DD-MM)
Return type : String - the timestamp
Exceptions : none
Caller : general
...
...
@@ -1477,6 +1494,20 @@ sub date_and_mem {
=cut
sub
date
{
return
strftime
"
%Y-%m-%d
",
localtime
;
}
=head2 date_and_time
Example : print "Date: " . $support->date . "\n";
Description : Prints a nicely formatted timestamp (YYYY-DD-MM hh:mm:ss)
Return type : String - the timestamp
Exceptions : none
Caller : general
=cut
sub
date_and_time
{
return
strftime
"
%Y-%m-%d %T
",
localtime
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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