aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-21 14:26:44 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-21 14:26:44 +0800
commit9edb9a21bce97594928f8660e8e32df2cb25b74d (patch)
treea933fa349621d842f361762045eabc96772d147d
parent4f5b362bda862b0d77583491d5e04193148a9349 (diff)
downloadgo-tangerine-9edb9a21bce97594928f8660e8e32df2cb25b74d.tar.gz
go-tangerine-9edb9a21bce97594928f8660e8e32df2cb25b74d.tar.zst
go-tangerine-9edb9a21bce97594928f8660e8e32df2cb25b74d.zip
Add json LogSystem #538
-rw-r--r--logger/log.go2
-rw-r--r--logger/logsystem.go24
-rw-r--r--logger/sys.go3
3 files changed, 27 insertions, 2 deletions
diff --git a/logger/log.go b/logger/log.go
index 2dbec86de..fab004d0a 100644
--- a/logger/log.go
+++ b/logger/log.go
@@ -30,6 +30,8 @@ func New(datadir string, logFile string, logLevel int, logFormat string) LogSyst
switch logFormat {
case "raw":
sys = NewRawLogSystem(writer, 0, LogLevel(logLevel))
+ case "json":
+ sys = NewJsonLogSystem(writer, 0, LogLevel(logLevel))
default:
sys = NewStdLogSystem(writer, log.LstdFlags, LogLevel(logLevel))
}
diff --git a/logger/logsystem.go b/logger/logsystem.go
index 8458b938f..1318a9f96 100644
--- a/logger/logsystem.go
+++ b/logger/logsystem.go
@@ -61,3 +61,27 @@ func (t *rawLogSystem) SetLogLevel(i LogLevel) {
func (t *rawLogSystem) GetLogLevel() LogLevel {
return LogLevel(atomic.LoadUint32(&t.level))
}
+
+// NewRawLogSystem creates a LogSystem that prints to the given writer without
+// adding extra information. Suitable for preformatted output
+func NewJsonLogSystem(writer io.Writer, flags int, level LogLevel) LogSystem {
+ logger := log.New(writer, "", 0)
+ return &jsonLogSystem{logger, uint32(level)}
+}
+
+type jsonLogSystem struct {
+ logger *log.Logger
+ level uint32
+}
+
+func (t *jsonLogSystem) LogPrint(level LogLevel, msg string) {
+ t.logger.Print(msg)
+}
+
+func (t *jsonLogSystem) SetLogLevel(i LogLevel) {
+ atomic.StoreUint32(&t.level, uint32(i))
+}
+
+func (t *jsonLogSystem) GetLogLevel() LogLevel {
+ return LogLevel(atomic.LoadUint32(&t.level))
+}
diff --git a/logger/sys.go b/logger/sys.go
index bd826b587..db4251a52 100644
--- a/logger/sys.go
+++ b/logger/sys.go
@@ -76,8 +76,7 @@ func dispatchLoop() {
func sysLoop(sys LogSystem, in <-chan message, wg *sync.WaitGroup) {
for msg := range in {
switch sys.(type) {
- case *rawLogSystem:
- // This is a semantic hack since rawLogSystem has little to do with JsonLevel
+ case *jsonLogSystem:
if msg.level == JsonLevel {
sys.LogPrint(msg.level, msg.msg)
}
ec95e528eaa1563e51d95c8c'>Update the url (and site name) for the KDE rdf. Bug #5145.Jason Leach2001-07-241-0/+5 * Add a `user_creatable' property to folder types and make componentsEttore Perazzoli2001-07-221-0/+6 * Revert last changes, URIs are now back to original in shell.Jason Leach2001-07-211-0/+5 * Update the evolution:/local/ URI's to evolution:/Local Folders/ to goJason Leach2001-07-201-2/+9 * HTMLIain Holmes2001-07-201-0/+4 * Fix the mail folder linksIain Holmes2001-07-201-0/+4 * Set the text colour to BLACKIain Holmes2001-07-201-0/+6 * More stuffIain Holmes2001-07-191-0/+8 * Remove spewageIain Holmes2001-07-191-0/+4 * Make the Tasks option workIain Holmes2001-07-191-0/+7 * Make pretty buttons.Iain Holmes2001-07-191-0/+6 * Cosmetic fixesIain Holmes2001-07-191-0/+5 * Nicer error reporting.Iain Holmes2001-07-171-0/+6 * Icon name fixIain Holmes2001-07-141-0/+4 * Set the property box changeIain Holmes2001-07-141-0/+5 * Convert the date string to utf8 before appending it to HTML.Chyla Zbigniew2001-07-141-0/+5 * include <config.h>Iain Holmes2001-07-131-0/+4 * i18n stuffIain Holmes2001-07-131-0/+6 * Minor glade changeIain Holmes2001-07-131-0/+4 * Secure e_summary_mail_generate_htmlIain Holmes2001-07-121-0/+5 * Fix the memory corruption issueIain Holmes2001-07-121-0/+7 * Free the data stop all the transfers when the summary is destroyed.Iain Holmes2001-07-121-0/+14 * Fix the register RDFIain Holmes2001-07-111-0/+4 * Alarm! Alarm!Iain Holmes2001-07-101-0/+7 * Get a lovely icon from jimmac for the type of weatherIain Holmes2001-07-101-0/+7 * Fix the big black line down the middle bugIain Holmes2001-07-101-0/+5 * Fix another HTML bugIain Holmes2001-07-101-0/+4 * Better time reportingIain Holmes2001-07-101-0/+5 * Fix HTML and show more than 1 days appointmentsIain Holmes2001-07-101-0/+6 * Make the tasks change to the tasks folder when clicked onIain Holmes2001-07-101-0/+5 * Added #include <config.h> to get translations working.Kjartan Maraas2001-07-091-0/+5 * Mail stuff addedIain Holmes2001-07-071-0/+12 * Fix bad selection clist stuffIain Holmes2001-07-071-0/+9 * Rename RDF to news feedIain Holmes2001-07-061-0/+5 * Some glade fixage.Iain Holmes2001-07-061-0/+5 * Hook up the Calendar toggle buttonsIain Holmes2001-07-061-0/+13 * NAmespace the My Evolution preferences correctlyIain Holmes2001-07-061-0/+6 * Fixed memory corruption, restoring settings reenabled.Iain Holmes2001-07-061-0/+5 * Disable bonobo-conf Fix radio button problemIain Holmes2001-07-041-0/+7 * Fixed the bonobo warningIain Holmes2001-07-041-0/+4 * BonoboConf work New print iconIain Holmes2001-07-041-0/+10 * Fix crashes if the offline button is clicked before the summary has been createdIain Holmes2001-07-041-0/+6 * New tasks stuffIain Holmes2001-07-031-0/+6 * I'm sorry JP, I can't edit MakefilesIain Holmes2001-07-021-0/+4 * Add `e-summary-preferences.h'.Ettore Perazzoli2001-07-021-0/+5 * Store URLs on disk.Iain Holmes2001-07-011-0/+9 * Use names in the clist, not the urlIain Holmes2001-07-011-0/+8 * Allow new RDFs to be added.Iain Holmes2001-07-011-0/+7 * Handle the online/offline stuffIain Holmes2001-07-011-0/+32 * Marked strings for translation + conversion to utf8.Chyla Zbigniew2001-06-301-0/+19 * Put in the hack to stop GtkHTML from returning to the top of the page.Iain Holmes2001-06-301-0/+5 * Fix a few buggiesIain Holmes2001-06-301-0/+9 * Configure My EvolutionIain Holmes2001-06-301-0/+41