syndicate-2017/racket/syndicate/trace.rkt

38 lines
1.2 KiB
Racket
Raw Normal View History

2015-03-04 16:16:18 +00:00
#lang racket/base
(provide trace-logger
trace-process-step
2015-03-21 16:30:10 +00:00
trace-process-step-result
trace-internal-action
trace-internal-action-result)
2015-03-04 16:16:18 +00:00
(require "hierarchy.rkt")
(require "pretty.rkt")
2015-03-04 16:16:18 +00:00
(define trace-logger (make-logger 'minimart-trace))
(define-syntax-rule (record-trace-event name r)
(when (log-level? trace-logger 'info)
(log-message trace-logger 'info name "" r #f)))
(define (cons-pid pid)
(if pid
(cons pid (current-actor-path-rev))
(current-actor-path-rev)))
;; Event (Option PID) Process -> Void
2015-03-21 16:30:10 +00:00
(define (trace-process-step e pid beh st)
(record-trace-event 'process-step (list (cons-pid pid) e beh st)))
2015-03-21 16:30:10 +00:00
;; Event (Option PID) Process (Option Exception) (Option Transition) -> Void
2015-03-21 16:30:10 +00:00
(define (trace-process-step-result e pid beh st exn t)
(record-trace-event 'process-step-result (list (cons-pid pid) e beh st exn t)))
2015-03-21 16:30:10 +00:00
;; (Option PID) Action Dataspace -> Void
2015-03-21 16:30:10 +00:00
(define (trace-internal-action pid a w)
(record-trace-event 'internal-action (list (cons-pid pid) a w)))
2015-03-04 16:16:18 +00:00
;; (Option PID) Action Dataspace Transition -> Void
2015-03-21 16:30:10 +00:00
(define (trace-internal-action-result pid a w t)
(record-trace-event 'internal-action-result (list (cons-pid pid) a w t)))