Added logging support using SLF4J backed by Log4J.

This commit is contained in:
Jonathan Bernard 2010-06-01 07:52:45 -05:00
parent 790d2c2a77
commit 966ebbf36a
10 changed files with 38 additions and 23 deletions

View File

@ -2,4 +2,4 @@
#Thu May 27 05:01:16 CDT 2010
app.griffon.version=0.3
app.name=pit-swing
app.version=2.4.0
app.version=2.5.0

View File

@ -0,0 +1,5 @@
import org.slf4j.LoggerFactory
onNewInstance = { klass, type, instance ->
instance.metaClass.logger = LoggerFactory.getLogger(klass.name)
}

View File

@ -17,49 +17,56 @@ class PITController {
model.issueListRenderer = new IssueTableCellRenderer()
File pitHome, pitrcFile, pitswingrcFile
boolean logDbg = logger.isDebugEnabled()
Properties config = new Properties()
// look for config directory
pitHome = new File(System.getProperty('user.home'), '.pit')
println "$pitHome is ${pitHome.exists() ? '' : 'not '} present."
if (logDbg) logger.debug("$pitHome is " +
(pitHome.exists() ? '' : 'not ') + "present.")
// look for general config options
pitrcFile = new File(pitHome, 'pitrc')
println "$pitrcFile is ${pitrcFile.exists() ? '' : 'not '} present."
if(logDbg) logger.debug("$pitrcFile is " +
(pitrcFile.exists() ? '' : 'not ') + "present.")
// load general config (if present)
if (pitrcFile.exists()) {
pitrcFile.withInputStream() { config.load(it) }
println "Loaded pitrc"
if (logDbg) logger.debug("Loaded pitrc")
}
// look for swing specific config
pitswingrcFile = new File(pitHome, 'pitswingrc')
println "$pitswingrcFile is " (pitswingrcFile.exists() ?
'' : 'not ') + "present."
if (logDbg) logger.debug("$pitswingrcFile is " +
(pitswingrcFile.exists() ? '' : 'not ') + "present.")
// load swing specific config (if present)
if (pitswingrcFile.exists()) {
pitswingrcFile.withInputStream() { config.load(it) }
println "Loaded pitswingrc"
if(logDbg) logger.debug("Loaded pitswingrc")
}
// Process Configurable Options
// ----------------------------
config.keySet().each { println it }
if (logDbg) {
logger.debug("Configurable properties:")
config.keySet().each { logger.debug(it) }
}
// add custom category templates
Category.values().each { category ->
def expectedKey = "issue." + category.name().toLowerCase() +
".template"
println "Looking for key: $expectedKey"
if(logDbg) logger.debug("Looking for key: $expectedKey")
config.keySet().each { currentKey ->
if (currentKey == expectedKey)
model.templates[(category)] =
config.getProperty(expectedKey, "")
println "Template for category $category: '" +
model.templates[(category)] + "'"
if (logDbg) logger.debug("Template for category $category: '" +
model.templates[(category)] + "'")
}
}
@ -71,7 +78,7 @@ class PITController {
def initRepos = config.getProperty('initial-repositories', '')
initRepos = initRepos.split(/[;:,]/)
initRepos.each { repoPath -> loadProject(new File(repoPath)) }
println "Init repos: '$initRepos'"
if(logDbg) logger.debug("Init repos: '$initRepos'")
}
// load custom issue CSS
@ -88,7 +95,7 @@ class PITController {
(cssFile = new File(issueCSS).exists()))
issueCSS = cssFile.text
println "CS for issue display: $issueCSS"
if (logDbg) logger.debug("CS for issue display: $issueCSS")
model.issueCSS = issueCSS
}

View File

@ -213,7 +213,8 @@ class ProjectPanelController {
result.append(line)
// add in the CSS information to the head
if (line =~/<head>/) result.append(model.issueCSS)
if (line =~/<head>/) result.append('<style type="text/css">' +
model.issueCSS + '</style>')
}
return result.toString()

View File

@ -22,13 +22,8 @@ import griffon.util.GriffonPlatformHelper
import griffon.util.GriffonApplicationHelper
GriffonPlatformHelper.tweakForNativePlatform(app)
SwingBuilder.lookAndFeel('mac', 'org.pushingpixels.substance.api.skin.SubstanceCremeCoffeeLookAndFeel', 'nimbus', ['metal', [boldFonts: false]])
SwingBuilder.lookAndFeel('org.pushingpixels.substance.api.skin.SubstanceCremeCoffeeLookAndFeel', 'nimbus', ['metal', [boldFonts: false]])
// make config directory
def confDir = new File(System.getProperty('user.home'), '.pit')
if (!confDir.exists()) confDir.mkdirs()
// find or create configuration file
def swingConf = new File(confDir, 'pit-swing.groovy')
if (!swingConf.exists()) swingConf.createNewFile()
// run config
GriffonApplicationHelper.runScriptInsideEDT(swingConf.canonicalPath, app)

View File

@ -1,4 +1,3 @@
<style type="text/css">
body {
font-size: small;
}
@ -21,4 +20,3 @@ h4 {
table,th,td{
border-style: solid;
}
</style>

View File

@ -0,0 +1,9 @@
log4j.rootLogger=DEBUG,stdout,fileout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout
log4j.appender.fileout=org.apache.log4j.FileAppender
log4j.appender.fileout.file=pit-swing.log
log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
log4j.appender.fileout.layout.ConversionPattern=%-5p %C %d{DATE}: %m%n

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
application.version=2.4.0
application.version=2.5.0