-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.fs
71 lines (60 loc) · 2.07 KB
/
log.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
\ log dump class
\ Copyright © 2011-2014 Bernd Paysan
\ This program is free software: you can redistribute it and/or modify
\ it under the terms of the GNU Affero General Public License as published by
\ the Free Software Foundation, either version 3 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 Affero General Public License for more details.
\ You should have received a copy of the GNU Affero General Public License
\ along with this program. If not, see <http://www.gnu.org/licenses/>.
reply-table $@ inherit-table log-table
scope{ net2o-base
\g
\g ### log commands ###
\g
net2o' token net2o: log-token ( $:token n -- )
64>n 0 .r ." :" $> forth:type space ;
$20 net2o: emit ( utf8 -- ) \g emit character on server log
64>n xemit ;
+net2o: type ( $:string -- ) \g type string on server log
$> forth:type ;
+net2o: cr ( -- ) \g newline on server log
forth:cr ;
0 warnings !@ \ disable warnings for .
+net2o: . ( n -- ) \g print number on server log
u64. ;
warnings !
+net2o: f. ( r -- ) \g print fp number on server log
forth:f. ;
+net2o: .time ( -- ) \g print timer to server log
forth:.time .packets profile( .times ) ;
+net2o: !time ( -- ) \g start timer
forth:!time init-timer ;
log-table $save
' context-table is gen-table
$32 net2o: log ( -- o:log )
log-context @ dup 0= IF
drop net2o:new-log dup log-context !
THEN n:>o ;
log-table >table
}scope
\\\
Local Variables:
forth-local-words:
(
(("net2o:" "+net2o:") definition-starter (font-lock-keyword-face . 1)
"[ \t\n]" t name (font-lock-function-name-face . 3))
("[a-z\-0-9]+(" immediate (font-lock-comment-face . 1)
")" nil comment (font-lock-comment-face . 1))
)
forth-local-indent-words:
(
(("net2o:" "+net2o:") (0 . 2) (0 . 2) non-immediate)
(("[:") (0 . 1) (0 . 1) immediate)
((";]") (-1 . 0) (0 . -1) immediate)
)
End:
[THEN]