| | 1 | |
| | 2 | = !Logging/Status API |
| | 3 | |
| | 4 | == Overview |
| | 5 | |
| | 6 | The logger handles status and non-status messages separately. |
| | 7 | The only reason that the logger is involved in status messages at all is so that non-tools can present status messages. |
| | 8 | Status messages are plain text only (though color can be specified). |
| | 9 | Non-status messages allow for plain text and/or HTML/image logging. |
| | 10 | |
| | 11 | == Non-Status Logging |
| | 12 | |
| | 13 | The logger offer three functions for non-status logging: `info()`, `warning()`, and `error()`. |
| | 14 | They all take the same arguments and keywords. |
| | 15 | The single mandatory argument is a text string (message), which can be empty. |
| | 16 | The optional keywords are: |
| | 17 | ||= Name =||= Default =||= Description =|| |
| | 18 | ||= '''add_newline''' =||= ''True'' =||=Append newline to text before logging =|| |
| | 19 | ||= '''image''' =||= ''None'' =||=A PIL image to log, in which case the text message is used as alt text for plain-text logs =|| |
| | 20 | ||= '''is_html''' =||= ''False'' =||=Is text message HTML? Use best effort to convert to plain text for plain-text logs =|| |
| | 21 | |
| | 22 | == Status Logging |
| | 23 | |
| | 24 | All graphical tools have a !ToolWindow instance that provides the interface area that the tool will build its user interface within. |
| | 25 | Such tools will issue status messages via the !ToolWindow's `status()` method. |
| | 26 | If available, the message will be shown in the tool's own status area (there is no such area in the current implementation). |
| | 27 | Otherwise the message (and arguments) will be forwarded to the logger's `status()` method, |
| | 28 | which in turn will forward to the main window's `status()` method. |
| | 29 | If there is no main window then the message will be dropped. |
| | 30 | Non-tools can issue status messages by calling the logger's `status()` method directly. |
| | 31 | |
| | 32 | All the various `status()` methods have the same call signature. The only mandatory argument is a plain text message string. |
| | 33 | The primary keyword arguments are: |
| | 34 | ||= Name =||= Default =||= Description =|| |
| | 35 | ||= '''color''' =||= "black" =||=Status text color =|| |
| | 36 | ||= '''log''' =||= ''False'' =||=Also log the message using `info()` =|| |
| | 37 | ||= '''secondary''' =||= ''False'' =||=Show message in the secondary status area =|| |
| | 38 | The secondary status area is typically used for "sub status" or very transitory messages. |
| | 39 | For example, when Chimera 1 saves a session it shows "Saving session…" in the primary status area |
| | 40 | and each sub step (''e.g.'' "Saving coordinates") is shown in the secondary area. |
| | 41 | Another example is when !MultAlign Viewer shows residue-association information as the mouse moves, |
| | 42 | it uses the secondary status area so that any primary status information isn't prematurely erased. |
| | 43 | |
| | 44 | Less frequently used keyword args are: |
| | 45 | ||= Name =||= Default =||= Description =|| |
| | 46 | ||= '''blank_after''' =||= ''None'' =||=Number of seconds to show the message before clearing. If ''None'', use user-specified default. =|| |
| | 47 | ||= '''follow_with''' =||= ''""'' =||=Follow first status with this text =|| |
| | 48 | ||= '''follow_time''' =||= ''20'' =||=How log, in seconds, before showing the '''follow_with''' text =|| |
| | 49 | ||= '''follow_log''' =||= ''None'' =||=Whether to log the '''follow_with''' message. If ''None'', use the '''log''' value. =|| |
| | 50 | Other keyword args may be added later as its determined that they're needed. |