Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sven Greiner
finf-ScalaAnnounceBot
Commits
20fb4011
Commit
20fb4011
authored
Aug 09, 2012
by
Sven Greiner
Browse files
Print time in log
parent
ed53f1c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/de/sammyshp/announcebot/Log.scala
View file @
20fb4011
package
de.sammyshp.announcebot
import
java.text.SimpleDateFormat
import
java.util.Date
object
Log
{
val
LEVEL_ERROR
=
1
val
LEVEL_WARNING
=
2
val
LEVEL_DEBUG
=
4
val
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
)
def
e
(
msg
:
String
)
{
log
(
LEVEL_ERROR
,
msg
)
}
...
...
@@ -18,10 +23,13 @@ object Log {
}
private
def
log
(
level
:
Int
,
msg
:
String
)
{
level
match
{
case
LEVEL_ERROR
=>
println
(
"ERROR: "
+
msg
)
case
LEVEL_WARNING
=>
println
(
"WARNING: "
+
msg
)
case
LEVEL_DEBUG
=>
println
(
"DEBUG: "
+
msg
)
}
println
(
"%-10s%-22s%s"
.
format
(
level
match
{
case
LEVEL_ERROR
=>
"ERROR"
case
LEVEL_WARNING
=>
"WARNING"
case
LEVEL_DEBUG
=>
"DEBUG"
},
dateFormat
.
format
(
new
Date
()),
msg
))
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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