[Zeitgeist] [Merge] lp:~rainct/zeitgeist/custom-log-handler into lp:zeitgeist
The proposal to merge lp:~rainct/zeitgeist/custom-log-handler into lp:zeitgeist has been updated. Status: Approved = Merged For more details, see: https://code.launchpad.net/~rainct/zeitgeist/custom-log-handler/+merge/93289 -- https://code.launchpad.net/~rainct/zeitgeist/custom-log-handler/+merge/93289 Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist. ___ Mailing list: https://launchpad.net/~zeitgeist Post to : zeitgeist@lists.launchpad.net Unsubscribe : https://launchpad.net/~zeitgeist More help : https://help.launchpad.net/ListHelp
Re: [Zeitgeist] [Merge] lp:~rainct/zeitgeist/custom-log-handler into lp:zeitgeist
Review: Approve Wooo, that will be nice! :) -- https://code.launchpad.net/~rainct/zeitgeist/custom-log-handler/+merge/93289 Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist. ___ Mailing list: https://launchpad.net/~zeitgeist Post to : zeitgeist@lists.launchpad.net Unsubscribe : https://launchpad.net/~zeitgeist More help : https://help.launchpad.net/ListHelp
[Zeitgeist] [Merge] lp:~rainct/zeitgeist/custom-log-handler into lp:zeitgeist
The proposal to merge lp:~rainct/zeitgeist/custom-log-handler into lp:zeitgeist has been updated. Status: Needs review = Approved For more details, see: https://code.launchpad.net/~rainct/zeitgeist/custom-log-handler/+merge/93289 -- https://code.launchpad.net/~rainct/zeitgeist/custom-log-handler/+merge/93289 Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist. ___ Mailing list: https://launchpad.net/~zeitgeist Post to : zeitgeist@lists.launchpad.net Unsubscribe : https://launchpad.net/~zeitgeist More help : https://help.launchpad.net/ListHelp
Re: [Zeitgeist] [Merge] lp:~rainct/zeitgeist/custom-log-handler into lp:zeitgeist
2012/2/17 Michal Hruby michal.hr...@canonical.com: Only WARNING and higher levels should be logged to stderr. Currently it's sending anything but debug to stderr. I tried :P. Yes, I wanted INFO and MESSAGE to also go to stdout. (But if you want to change that, fine with me). Also, one thing I dont like about glib's default log handler is that it doesn't print time, could we do that? To the file, sure (it's in the commented code). To std{out,err}, wth would you do that, it's just cluttering stuff up. It's pretty valuable when you're just reading the log and wondering if something happened in the same millisecond or a couple of hours apart. -- https://code.launchpad.net/~rainct/zeitgeist/custom-log-handler/+merge/93289 Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist. ___ Mailing list: https://launchpad.net/~zeitgeist Post to : zeitgeist@lists.launchpad.net Unsubscribe : https://launchpad.net/~zeitgeist More help : https://help.launchpad.net/ListHelp
Re: [Zeitgeist] [Merge] lp:~rainct/zeitgeist/custom-log-handler into lp:zeitgeist
Review: Needs Fixing 73 +if ((log_levels LogLevelFlags.LEVEL_DEBUG) != 0) 74 +output = stdout; Only WARNING and higher levels should be logged to stderr. -- https://code.launchpad.net/~rainct/zeitgeist/custom-log-handler/+merge/93289 Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist. ___ Mailing list: https://launchpad.net/~zeitgeist Post to : zeitgeist@lists.launchpad.net Unsubscribe : https://launchpad.net/~zeitgeist More help : https://help.launchpad.net/ListHelp
Re: [Zeitgeist] [Merge] lp:~rainct/zeitgeist/custom-log-handler into lp:zeitgeist
2012/2/17 Michal Hruby michal.hr...@canonical.com: Only WARNING and higher levels should be logged to stderr. Currently it's sending anything but debug to stderr. I tried :P. (But if you want to change that, fine with me). Also, one thing I dont like about glib's default log handler is that it doesn't print time, could we do that? To the file, sure (it's in the commented code). To std{out,err}, wth would you do that, it's just cluttering stuff up. -- https://code.launchpad.net/~rainct/zeitgeist/custom-log-handler/+merge/93289 Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist. ___ Mailing list: https://launchpad.net/~zeitgeist Post to : zeitgeist@lists.launchpad.net Unsubscribe : https://launchpad.net/~zeitgeist More help : https://help.launchpad.net/ListHelp
[Zeitgeist] [Merge] lp:~rainct/zeitgeist/custom-log-handler into lp:zeitgeist
Siegfried Gevatter has proposed merging lp:~rainct/zeitgeist/custom-log-handler into lp:zeitgeist with lp:~rainct/zeitgeist/matches-template as a prerequisite. Requested reviews: Zeitgeist Framework Team (zeitgeist) For more details, see: https://code.launchpad.net/~rainct/zeitgeist/custom-log-handler/+merge/93289 -- https://code.launchpad.net/~rainct/zeitgeist/custom-log-handler/+merge/93289 Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~rainct/zeitgeist/custom-log-handler into lp:zeitgeist. === modified file 'src/Makefile.am' --- src/Makefile.am 2012-02-02 18:57:35 + +++ src/Makefile.am 2012-02-15 19:59:18 + @@ -37,6 +37,7 @@ extension.vala \ extension-collection.vala \ extension-store.vala \ + logging.vala \ notify.vala \ sql.vala \ utils.vala \ === added file 'src/logging.vala' --- src/logging.vala 1970-01-01 00:00:00 + +++ src/logging.vala 2012-02-15 19:59:18 + @@ -0,0 +1,106 @@ +/* logging.vala + * + * Copyright © 2012 Canonical Ltd. + * By Siegfried-A. Gevatter siegfried.gevat...@collabora.co.uk + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + */ + +namespace Zeitgeist +{ +namespace Logging +{ + +private string get_log_level_string (LogLevelFlags log_levels) +{ +string log_level; + +if ((log_levels LogLevelFlags.LEVEL_ERROR) != 0) +log_level = ERROR; +else if ((log_levels LogLevelFlags.LEVEL_CRITICAL) != 0) +log_level = CRITICAL; +else if ((log_levels LogLevelFlags.LEVEL_WARNING) != 0) +log_level = WARNING; +else if ((log_levels LogLevelFlags.LEVEL_MESSAGE) != 0) +log_level = MESSAGE; +else if ((log_levels LogLevelFlags.LEVEL_INFO) != 0) +log_level = INFO; +else if ((log_levels LogLevelFlags.LEVEL_DEBUG) != 0) +log_level = DEBUG; +else +log_level = UNKNOWN; + +return log_level; +} + +private void log_handler (string? log_domain, LogLevelFlags log_levels, +string message) +{ +string log_level = get_log_level_string (log_levels); +//string timestamp = new DateTime.now_local ().format ( +//%Y-%m-%d %H:%M:%S); +// FIXME: get PID + +unowned FileStream output; +if ((log_levels LogLevelFlags.LEVEL_DEBUG) != 0) +output = stdout; +else +output = stderr; +output.printf (** %s: %s\n, log_level, message); + +// FIXME: log to file +//printf ([%s] - %s - %s\n, timestamp, log_level, message); +} + +public void setup_logging (string? log_level) +{ +LogLevelFlags discarded = LogLevelFlags.LEVEL_DEBUG; +if (log_level != null) +{ +var ld = LogLevelFlags.LEVEL_DEBUG; +var li = LogLevelFlags.LEVEL_INFO; +var lm = LogLevelFlags.LEVEL_MESSAGE; +var lw = LogLevelFlags.LEVEL_WARNING; +var lc = LogLevelFlags.LEVEL_CRITICAL; +switch (log_level.up ()) +{ +case DEBUG: +discarded = 0; +break; +case INFO: +discarded = ld; +break; +case WARNING: +discarded = ld | li | lm; +break; +case CRITICAL: +discarded = ld | li | lm | lw; +break; +case ERROR: +discarded = ld | li | lm | lw | lc; +break; +} +} +if (discarded != 0) +Log.set_handler (null, discarded, () = {}); + +LogLevelFlags logged = ~discarded ~LogLevelFlags.FLAG_RECURSION; +Log.set_handler (null, logged, log_handler); +} + +} +} + +// vim:expandtab:ts=4:sw=4 === modified file 'src/zeitgeist-daemon.vala' --- src/zeitgeist-daemon.vala 2012-02-07 12:46:46 + +++ src/zeitgeist-daemon.vala 2012-02-15 19:59:18 +