net2o-log.fs 2 KB
Newer Older
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
\ log dump class

\ Copyright (C) 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

get-current also net2o-base definitions

net2o' token net2o: log-token ( $:token n -- )
    64>n 0 .r ." :" $> F type space ;

$20 net2o: emit ( utf8 -- ) \ emit character on server log
    64>n xemit ;
+net2o: type ( $:string -- ) \ type string on server log
    $> F type ;
bernd's avatar
bernd committed
29 30
+net2o: cr ( -- ) \ newline on server log
    F cr ;
31 32 33 34 35 36 37 38 39 40 41 42
+net2o: . ( n -- ) \ print number on server log
    64. ;
+net2o: f. ( r -- ) \ print fp number on server log
    F f. ;
+net2o: .time ( -- ) \ print timer to server log
    F .time .packets profile( .times ) ;
+net2o: !time ( -- ) \ start timer
    F !time init-timer ;

gen-table $freeze
' context-table is gen-table

bernd's avatar
bernd committed
43 44 45 46
$32 net2o: log ( -- o:log )
    log-context @ dup 0= IF
	drop  n2o:new-log dup log-context !
    THEN  n:>o ;
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
log-table >table

previous set-current

0 [IF]
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]