1 ! Copyright (C) 2018 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs calendar combinators environment
4 escape-strings io io.pathnames io.streams.string kernel math
5 math.parser namespaces prettyprint prettyprint.config sequences
6 tools.deploy.backend tools.time unix.groups unix.users uuid ;
11 cwd uid euid gid egid out elapsed os-envs-after process ;
13 : ci-run-process ( process -- timestamp os-envs cwd uid euid gid egid out elapsed os-envs' process )
16 now-gmt os-envs current-directory get
17 real-user-id effective-user-id
18 real-group-id effective-group-id
20 '[ _ run-with-output ] with-string-writer
24 : ci-run-process>autopsy ( process -- autopsy )
25 ci-run-process process-autopsy boa ;
27 : unparse-full ( obj -- str )
28 [ unparse ] without-limits ;
30 : autopsy. ( autopsy -- )
32 [ drop "<AUTOPSY: " uuid4 append print nl ]
34 bl bl timestamp>> timestamp>unix-time >float number>string
35 "unix-time" tag-payload print nl
38 bl bl elapsed>> number>string "elapsed-nanos" tag-payload print nl
41 bl bl cwd>> "cwd" tag-payload print nl
44 bl bl uid>> number>string "uid" tag-payload print nl
47 bl bl euid>> number>string "euid" tag-payload print nl
50 bl bl gid>> number>string "gid" tag-payload print nl
53 bl bl egid>> number>string "egid" tag-payload print nl
56 bl bl os-envs>> unparse-full "os-envs" tag-payload print nl
59 bl bl os-envs>> unparse-full "os-envs-after" tag-payload print nl
62 bl bl [ os-envs-after>> ] [ os-envs>> ] bi assoc-diff unparse-full "os-envs-diff" tag-payload print nl
65 bl bl [ os-envs>> ] [ os-envs-after>> ] bi assoc-diff unparse-full "os-envs-swap-diff" tag-payload print nl
68 bl bl process>> unparse-full "process" tag-payload print nl
71 bl bl out>> "out" tag-payload print nl
73 [ drop ";AUTOPSY>" print ]