mirror of
https://github.com/sorenisanerd/gotty.git
synced 2024-11-22 12:24:25 +00:00
writes log
This commit is contained in:
parent
a7d7ea6629
commit
73f0ca5a2f
10
README.md
10
README.md
@ -151,7 +151,7 @@ When you want to create a jailed environment for each client, you can use Docker
|
||||
$ gotty -w docker run -it --rm busybox
|
||||
```
|
||||
|
||||
## Operation log
|
||||
## Writes log
|
||||
|
||||
User's input in terminal can be found in logs. for example:
|
||||
|
||||
@ -164,7 +164,7 @@ if you run gotty like this:
|
||||
this is `test.sh`:
|
||||
|
||||
```sh
|
||||
# !/bin/bash
|
||||
#!/bin/bash
|
||||
|
||||
echo "Welcome: $4"
|
||||
kubectl -n $1 exec -it $2 -c $3 -- sh
|
||||
@ -174,12 +174,12 @@ visit `http://127.0.0.1:8080/?arg=without-istio&arg=sleep-7b6d569576-57sjq&arg=s
|
||||
|
||||
```
|
||||
...
|
||||
2022/11/13 10:48:12 [oplog] lsCR {"arg":["without-istio","sleep-7b6d569576-57sjq","sleep","21001713"]}
|
||||
2022/11/13 10:48:14 [oplog] pwdCR {"arg":["without-istio","sleep-7b6d569576-57sjq","sleep","21001713"]}
|
||||
2022/11/13 10:48:12 [wlog] lsCR {"arg":["without-istio","sleep-7b6d569576-57sjq","sleep","21001713"]}
|
||||
2022/11/13 10:48:14 [wlog] pwdCR {"arg":["without-istio","sleep-7b6d569576-57sjq","sleep","21001713"]}
|
||||
...
|
||||
```
|
||||
|
||||
Using the `[oplog]` flag, you can collect and store these logs persistently. All args are in the log, including the userID.
|
||||
Using the `[wlog]` flag, you can collect and store these logs persistently. All args are in the log, including the userID.
|
||||
|
||||
## Development
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
package utils
|
||||
|
||||
func FormatOperationLog(line *[]byte) (log string) {
|
||||
func FormatWriteLog(line *[]byte) (log string) {
|
||||
ascii := map[byte]string{
|
||||
0: "", //NUL
|
||||
0: "NUL",
|
||||
1: "SOH",
|
||||
2: "STX",
|
||||
3: "ETX",
|
||||
|
@ -194,7 +194,8 @@ func (wt *WebTTY) handleMasterReadEvent(data []byte, line *[]byte) error {
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to marshal arguments map")
|
||||
}
|
||||
log.Printf("[oplog] %s %s\n", utils.FormatOperationLog(line), string(argumentsByte))
|
||||
log.Printf("[wlog] %v\n", line)
|
||||
log.Printf("[wlog] %s %s\n", utils.FormatWriteLog(line), string(argumentsByte))
|
||||
*line = nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user