Closed (fixed)
Project:
Drush
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
26 Aug 2007 at 04:04 UTC
Updated:
9 Mar 2010 at 13:40 UTC
Jump to comment: Most recent file
after doing a 'watchdog show', i sometimes want detail on a record. i would like to pass watchdog show and see that whole watchdog record. i think the shosw function could automcatically take this action when 'type' param is numeric.
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | 170583.patch | 2.14 KB | jonhattan |
| #18 | 170583.patch | 20.21 KB | jonhattan |
| #15 | 170583.patch | 18.29 KB | jonhattan |
| #12 | 170583.patch | 22.25 KB | jonhattan |
| #9 | 170583.patch | 22.2 KB | jonhattan |
Comments
Comment #1
moshe weitzman commentedComment #2
moshe weitzman commentedStill valid.
Comment #3
jonhattanI was to work on that but... the possible changes are greater than initially expected.
* There's a bug for D5: `watchdog_severity_levels()` is not available.
* I think queries for D5,6 and D7 can be unified.
* Code needs some refactoring to print a complete message vs a table. Including queries.
User interface:
1. change `drush ws type` to `drush ws --type=php`
2. use `drush ws 42` to show a full message.
3. Add the warning id to a new column to the listing as:
4. Do not use dt() for type and severity. "actualizar" is the spanish for "update". One must do "--type=update" so it's a nonsense.
5. new command `drush watchdog-list` to list severity levels or message types. Severity levels are not the same for D5 and D6,7. otoh message types are obtained querying the database. I think we havn't the necessary bootstrap to show them in the command help. perhaps i'm wrong.
New possibilities with above changes:
* Remove a message
drush watchdog-delete 119* Remove messages of a type
drush watchdog-delete --type=locale(currentlydrush watchdog-delete locale)* Remove messages of a severity
drush watchdog-delete --severity=4* Perhaps use --limit=100 to remove al messages but recent 100.
* Make all those filters work together
It could be also of interest to use the argument as a string to filter by message text. ie,
drush watchdog-delete "Parsed JavaScript file".May I go for it?
Comment #4
moshe weitzman commentedThis all sounds great. Yes, please do go for it.
Comment #5
jonhattanI've not had the time to finish this yet but I think it's needed to give some feedback, so here is a unfinished but functional patch.
Changes:
* Include #700608: wrappers for database operations . Currently only drush_db_select(). For the watchdog is also needed drush_db_delete().
* New command watchdog-list: Show watchdog severity levels and message types.
* Aliases rearrangement:
d) New syntax for wd-show:
wd-show's table now includes the wid.
Remarcable changes in code:
* The command callback for wd-show goes to ...show_one() or ...show_many() depending of the param type (numeric: show a message in detail).
* both drush_core_watchdog_show_one() and ..many() uses a common function core_watchdog_format_result(). This is the place to format a watchdog result from db (truncate message, timestamp conversion, etc).
* New function core_watchdog_query() build a "WHERE" string based on given options (count, severity, type). This function is used by wd-show and wd-delete. The generated query piece uses named placeholders and is compatible with all drupal versions by using drush_db_select() (and drush_db_delete()).
Those functions need to be merged somehow:
* core_watchdog_format_result() and drush_watchdog_format_message(). Former formats a whole row (message, timestamp,..), the second one only formats the message and is used by system_watchdog().
* core_watchdog_severity_levels() and drush_watchdog_severity_levels(). Former returns severity levels as provided by drupal (localized). Second one alter the severity levels: no t() is fine (I prefer it) but mapping (emerg,alert,critical) to error for compatibility with _drush_print_log() breaks filtering wd-show results, as --severity=critical will raise an error because 'critical' is no longer a value of the array returned by drush_watchdog_severity_levels().
Changes to watchdog-delete are still a work in progress. It will implement almost same options as wd-show. I need to think of --count possible behaviours (delete all but latest 10, ¿delete latest 10? --count=all? no count means all?).
Moshe: I've seen your changes in:
* http://drupal.org/cvs?commit=325510 (strip_tags for message)
* http://drupal.org/cvs?commit=329444 (format_date, theme(uid), truncate to 188 ?)
I've ported strip_tags and proper theming for uid but your format_date custom format is not appropriate for all localizations and also I don't do truncate the message (no special preferences for this but it seems larger messages are not useful when truncated).
Comment #6
jonhattanPatch including wd-delete.
Function system_watchdog() is useless. Drupal never calls this function because drush is not a module. See
http://api.drupal.org/api/function/watchdog
So we can remove system_watchdog(), drush_watchdog_severity_levels() and drush_watchdog_format_message().
Comment #7
moshe weitzman commentedsystem.module exists and is loaded on every full drupal request and most every drush request. our system_watchdog() is getting called and reporting back errors faithfully. use -v or -d to see them. its a bit sneaky for drush to implement a function that belongs to system namespace but such is life.
Comment #8
jonhattanI'm unable to see it work here. I'll test again tomorrow.
Comment #9
jonhattanReported my problems with system_watchdog at #721060: system_watchdog and D6.
Attached patch:
1. Remove drush_watchdog_severity_levels() from drush.inc in favor of core_watchdog_severity_levels() in watchdog.drush.inc. This implementation is not tweaked for _drush_print_log.
2. Remove drush_watchdog_format_message(). Code integrated in system_watchdog(). Watchdog commands now use core_watchdog_format_result().
3. Due to 1) now severity levels are not localized.
4. Timestamp: I don't feel comfortable with
format_date($result->timestamp, 'small')(depends on timezone) norformat_date($watchdog->timestamp, 'custom', 'Y.n.j G.i.s'). I propose this short and non-confusing format "05/Jul 00:09".---
About the table:
* As said, new column wid has been incorporated.
* I think the user column is dispensable. This data is available in the full view.
* No truncate of messages is done now. Which is the magical number?
Remember this patch already include code in #700608: wrappers for database operations.
Comment #10
moshe weitzman commentedi'm ok with dropping the user column.
i'd say we should truncate message wherever it is now. thats what felt right at the time i last considered it.
Comment #11
jonhattanNew patch with truncate_utf8() as before and user column suppresed.
wd-delete does not use --count. Is there any interest in removing recent or oldest 100 messages? Perhaps it is more adequate to remove messages before a given date.
Comment #12
jonhattanthe patch
Comment #13
moshe weitzman commentedlets leave ws as a supported alias. dashes in aliases are no fun, and i am fond of ws.
I wonder if we should use drush_choice() here. Selecting a level or type would issue a show with that criteria.
it is slightly clearer for these to use drush_set_error()
Powered by Dreditor.
Comment #14
jonhattanI don't like drush_choice() for a watchdog operation because it provide its own keys/choices starting with 0:Cancel. In show and delete, a severity level can be referred by key or value (0: emergency, 1: alert,..) and moving keys +1 seems confusing. On the other hand message types are obtained from database and feeding drush_choice() with them does not present such an inconsistency.
Also introducing drush_choice() in wd-list will prompt the user two times to select severity a/o type. Or we
provide a ugly severity+levels mixture.
Other idea is to use drush_choice() in wd-show when the user enters a wrong severity or type. In that case I'd like to alter drush_choice() to make it able to skip the cancel option. I'll do a try on this.
Comment #15
jonhattanThis patch uses drush_choice() if a wrong type or severity is provided for show/delete. No cancel option skipped. Severity levels are no coincident but we can live with that. Perhaps moving 0:Cancel to c:Cancel is an option.
it also add ws as valid alias.
Comment #16
moshe weitzman commentedI was thinking "ugly severity+levels mixture". just separate the two by a choice which whose value is =======. i don't think anyone will mind. if you do levels last, the choice numbers won't even be close to the the int of the level. i think this is fine. we would show the choice value as Emergency (1).
"Other idea is to use drush_choice() in wd-show when the user enters a wrong severity or type. ". i think thats too edge case to be useful.
Comment #17
greg.1.anderson commentedIf you want to get rid of 0 == Cancel, I would recommend [Return] == Cancel (which works as a synonym for "0" today). Also, if you use "====" or "----" as a separator line, it would be easy enough to get Drush choice to not number any item whose key value is, say, an empty string.
Comment #18
jonhattannew patch with drush_choice() for wd-list and the replacement of drush_log() with drush_set_error().
changes to drush_choice() are:
* indentation of two.
* allow to provide more than one separator. Separators are options with a key starting with '-'.
Comment #19
greg.1.anderson commentedThat is nifty, but I'm not sure that it is a good idea to make any key starting with a '-' a separator line, as someone might want their key values to start with a '-'. How about instead: key starts with '-- ' and ends with ' --'? (note spaces)
e.g.
and
Warning: untested code, just an example.
Comment #20
moshe weitzman commentedI really like the drush_choice implementation. I've committed this with minor change to initial case the fields in the record detail view.
We can tidy up drush_choice and other stuff in follow-ups.
Comment #21
moshe weitzman commentedComment #22
jonhattanLittle patch with Greg's suggestion to use keys of the form "-- something --".
Comment #23
moshe weitzman commentedcommited