Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mirrors
biopet.biopet
Commits
5d02c94a
Commit
5d02c94a
authored
Jun 23, 2015
by
Wai Yi Leung
Browse files
Merge branch 'feature-force_logging' into 'develop'
Force logging to a file see #158 See merge request !175
parents
c67a1b6e
62ab9637
Changes
2
Hide whitespace changes
Inline
Side-by-side
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/PipelineCommand.scala
View file @
5d02c94a
...
...
@@ -15,10 +15,12 @@
*/
package
nl.lumc.sasc.biopet.core
import
org.apache.log4j.
{
PatternLayout
,
Appender
,
WriterAppender
,
FileAppender
}
import
org.broadinstitute.gatk.queue.util.
{
Logging
=>
GatkLogging
}
import
java.io.File
import
java.io.
{
PrintWriter
,
File
}
import
nl.lumc.sasc.biopet.core.config.Config
import
nl.lumc.sasc.biopet.core.workaround.BiopetQCommandLine
import
scala.collection.JavaConversions._
/** Wrapper around executable from Queue */
trait
PipelineCommand
extends
MainCommand
with
GatkLogging
{
...
...
@@ -64,9 +66,18 @@ trait PipelineCommand extends MainCommand with GatkLogging {
}
}
val
logDir
:
File
=
new
File
(
Config
.
global
.
map
.
getOrElse
(
"output_dir"
,
"./"
).
toString
+
File
.
separator
+
".log"
)
logDir
.
mkdirs
()
val
logFile
=
new
File
(
logDir
,
"biopet."
+
BiopetQCommandLine
.
timestamp
+
".log"
)
val
a
=
new
WriterAppender
(
new
PatternLayout
(
"%-5p [%d] [%C{1}] - %m%n"
),
new
PrintWriter
(
logFile
))
logger
.
addAppender
(
a
)
var
argv
:
Array
[
String
]
=
Array
()
argv
++=
Array
(
"-S"
,
pipeline
)
argv
++=
args
if
(!
args
.
contains
(
"--log_to_file"
)
&&
!
args
.
contains
(
"-log"
))
{
argv
++=
List
(
"--log_to_file"
,
logFile
.
getAbsolutePath
.
replace
(
"biopet"
,
"queue"
))
}
BiopetQCommandLine
.
main
(
argv
)
}
}
\ No newline at end of file
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/workaround/BiopetQCommandLine.scala
View file @
5d02c94a
...
...
@@ -94,6 +94,8 @@ object BiopetQCommandLine extends GatkLogging {
if
(
CommandLineProgram
.
result
!=
0
)
System
.
exit
(
CommandLineProgram
.
result
)
}
val
timestamp
=
System
.
currentTimeMillis
}
/**
...
...
@@ -124,7 +126,7 @@ class BiopetQCommandLine extends CommandLineProgram with Logging {
org
.
apache
.
commons
.
io
.
IOUtils
.
copy
(
is
,
os
)
os
.
close
()
val
s
=
if
(
t
.
getName
.
endsWith
(
"/"
))
t
.
getName
.
substring
(
0
,
t
.
getName
.
length
-
1
)
else
t
.
getName
pipelineName
=
s
.
substring
(
0
,
s
.
lastIndexOf
(
"."
))
+
"."
+
System
.
currentTimeMillis
pipelineName
=
s
.
substring
(
0
,
s
.
lastIndexOf
(
"."
))
+
"."
+
BiopetQCommandLine
.
timestamp
}
// override createByType to pass the correct exceptions
...
...
Write
Preview
Supports
Markdown
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!
Cancel
Please
register
or
sign in
to comment