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