MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | |
| 2 | #pragma strict_types,save_types |
| 3 | #pragma no_clone,no_shadow |
| 4 | |
| 5 | #include <daemon.h> |
| 6 | #include <logging.h> |
| 7 | |
| 8 | static int d_start, d_end, e_start, e_end; |
| 9 | |
| 10 | protected void create() |
| 11 | { |
| 12 | d_end = d_start = e_end = e_start = file_size(__DEBUG_LOG__); |
| 13 | } |
| 14 | |
Zesstra | 39d1d2b | 2020-09-28 23:53:04 +0200 | [diff] [blame] | 15 | int ch_check_access( string ch, object pl, string cmd, string txt ) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 16 | { |
| 17 | mixed tmp; |
| 18 | |
Arathorn | bf1008d | 2020-08-06 21:49:22 +0200 | [diff] [blame] | 19 | if ( ch != "debug" && ch != "entwicklung" && ch != "warnungen" ) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 20 | return 0; |
Arathorn | 52b877e | 2021-03-28 12:48:20 +0200 | [diff] [blame] | 21 | |
Arathorn | bf1008d | 2020-08-06 21:49:22 +0200 | [diff] [blame] | 22 | ch = capitalize(ch); |
| 23 | |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 24 | if( objectp(pl) && query_once_interactive(pl) && query_wiz_level(pl) > 15 ) |
| 25 | switch(cmd){ |
| 26 | case C_FIND: |
| 27 | case C_LIST: |
| 28 | case C_JOIN: |
| 29 | case C_LEAVE: |
| 30 | return 1; |
| 31 | case C_SEND: |
| 32 | // Wer (noch) nicht auf dem Kanal ist, bekommt auch keine |
| 33 | // Ausgabe - sonst gibt es selbige doppelt, da der CHMASTER |
| 34 | // einen automatisch den Kanal betreten laesst ... |
Vanion | 5065232 | 2020-03-10 21:13:25 +0100 | [diff] [blame] | 35 | if ( !objectp(pl) || |
| 36 | !pointerp(tmp=({string*})pl->QueryProp(P_CHANNELS)) || |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 37 | member( tmp, lower_case(ch) ) == -1 ) |
| 38 | return 1; |
| 39 | |
Arathorn | 1f4233b | 2021-04-02 15:09:46 +0200 | [diff] [blame] | 40 | switch( lower_case(txt||"") ){ |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 41 | case "backtrace": |
| 42 | { |
| 43 | string bt, log; |
| 44 | int start, end; |
| 45 | |
| 46 | if ( ch == "Debug" ) { |
| 47 | start = d_start; |
| 48 | end = d_end; |
| 49 | } |
| 50 | else if (ch == "Entwicklung") { |
| 51 | start = e_start; |
| 52 | end = e_end; |
| 53 | } |
| 54 | else if (ch == "Warnungen") { |
| 55 | pl->Message( "[" + ch + ":] Backtrace fuer Warnungen " |
| 56 | "nicht verfuegbar!\n"); |
| 57 | return 0; |
| 58 | } |
| 59 | else return(1); |
| 60 | |
| 61 | if( start >= end ) |
| 62 | bt = "[" + ch + ":] Kein Backtrace verfuegbar!\n"; |
| 63 | else { |
Zesstra | edeb226 | 2019-11-04 23:47:23 +0100 | [diff] [blame] | 64 | log = regreplace( |
| 65 | to_text(read_bytes( __DEBUG_LOG__, start, |
| 66 | min(end-start, 10000)), |
| 67 | "UTF-8") |
| 68 | || "\nFehler beim Einlesen des Debuglogs: " |
| 69 | "Kein Backtrace verfuegbar!\n", |
| 70 | "(Misplaced|current_object|" |
| 71 | "Connection|Host)[^\n]*\n", |
| 72 | "", 1 ); |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 73 | bt = "[" + ch + ":] -- BACKTRACE BEGIN --\n" |
| 74 | + log |
| 75 | + "[" + ch + ":] -- BACKTRACE END --\n"; |
| 76 | } |
Zesstra | edeb226 | 2019-11-04 23:47:23 +0100 | [diff] [blame] | 77 | |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 78 | call_out( symbol_function( "Message", pl ), 0, bt ); |
| 79 | } |
| 80 | break; |
| 81 | |
| 82 | default: |
| 83 | if ( ch != "Warnungen" ) { |
| 84 | pl->Message( "[" + ch + ":] Hilfe...\n" |
| 85 | "[" + ch + ":] Folgende Kommandos stehen zur " |
| 86 | "Verfuegung:\n" |
| 87 | "[" + ch + ":] 'backtrace' -- sendet den " |
| 88 | "Backtrace zum Fehler\n" |
| 89 | "[" + ch + ":] 'hilfe' -- sendet diese " |
| 90 | "Hilfeseite\n"); |
| 91 | } |
| 92 | else { |
| 93 | pl->Message( "[" + ch + ":] Keine Kommandos verfuegbar!\n"); |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | return 0; |
| 99 | } |
| 100 | |
| 101 | string name() { return "<Debugger>"; } |
| 102 | string Name() { return "<Debugger>"; } |
| 103 | |
| 104 | void ChannelMessage( mixed a ) |
| 105 | { |
| 106 | int fs; |
| 107 | |
| 108 | fs = file_size(__DEBUG_LOG__); |
| 109 | |
| 110 | switch( a[0] ){ |
Arathorn | bf1008d | 2020-08-06 21:49:22 +0200 | [diff] [blame] | 111 | case "debug": |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 112 | if ( fs > d_end && fs > e_end ){ |
| 113 | d_start = max((d_end > e_end ? d_end : e_end),0); |
| 114 | d_end = fs; |
| 115 | } |
| 116 | else if (fs < d_start || fs <= d_end) { |
| 117 | // Debuglog wurde wohl neu geoeffnet. |
| 118 | d_start = d_end = e_start = e_end = fs; |
| 119 | } |
| 120 | break; |
| 121 | |
Arathorn | bf1008d | 2020-08-06 21:49:22 +0200 | [diff] [blame] | 122 | case "entwicklung": |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 123 | if ( fs > d_end && fs > e_end ){ |
| 124 | e_start = max((e_end > d_end ? e_end : d_end),0); |
| 125 | e_end = fs; |
| 126 | } |
| 127 | else if (fs < e_start || fs <= e_end) { |
| 128 | // Debuglog wurde wohl neu geoeffnet. |
| 129 | d_start = d_end = e_start = e_end = fs; |
| 130 | } |
| 131 | break; |
| 132 | } |
| 133 | } |
| 134 | |