Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spark
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
Model registry
Operate
Environments
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
cs525-sp18-g07
spark
Commits
db623def
Commit
db623def
authored
14 years ago
by
Matei Zaharia
Browse files
Options
Downloads
Patches
Plain Diff
Added Logging trait
parent
c7d233b9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/scala/spark/Logging.scala
+44
-0
44 additions, 0 deletions
src/scala/spark/Logging.scala
with
44 additions
and
0 deletions
src/scala/spark/Logging.scala
0 → 100644
+
44
−
0
View file @
db623def
package
spark
import
org.slf4j.Logger
import
org.slf4j.LoggerFactory
/**
* Utility trait for classes that want to log data. Creates a SLF4J logger
* for the class and allows logging messages at different levels using
* methods that only evaluate parameters lazily if the log level is enabled.
*/
trait
Logging
{
// Make the log field transient so that objects with Logging can
// be serialized and used on another machine
@transient
private
var
log_
:
Logger
=
null
// Method to get or create the logger
def
log
:
Logger
=
{
if
(
log_
==
null
)
log_
=
LoggerFactory
.
getLogger
(
this
.
getClass
())
return
log_
}
// Log methods that take only a String
def
logInfo
(
msg
:
=>
String
)
=
if
(
log
.
isInfoEnabled
)
log
.
info
(
msg
)
def
logDebug
(
msg
:
=>
String
)
=
if
(
log
.
isDebugEnabled
)
log
.
debug
(
msg
)
def
logWarning
(
msg
:
=>
String
)
=
if
(
log
.
isWarnEnabled
)
log
.
warn
(
msg
)
def
logError
(
msg
:
=>
String
)
=
if
(
log
.
isErrorEnabled
)
log
.
error
(
msg
)
// Log methods that take Throwables (Exceptions/Errors) too
def
logInfo
(
msg
:
=>
String
,
throwable
:
Throwable
)
=
if
(
log
.
isInfoEnabled
)
log
.
info
(
msg
)
def
logDebug
(
msg
:
=>
String
,
throwable
:
Throwable
)
=
if
(
log
.
isDebugEnabled
)
log
.
debug
(
msg
)
def
logWarning
(
msg
:
=>
String
,
throwable
:
Throwable
)
=
if
(
log
.
isWarnEnabled
)
log
.
warn
(
msg
,
throwable
)
def
logError
(
msg
:
=>
String
,
throwable
:
Throwable
)
=
if
(
log
.
isErrorEnabled
)
log
.
error
(
msg
,
throwable
)
}
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