mirror of
https://github.com/sorenisanerd/gotty.git
synced 2024-11-26 13:44:24 +00:00
writes log
This commit is contained in:
parent
a7d7ea6629
commit
73f0ca5a2f
@ -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
|
$ gotty -w docker run -it --rm busybox
|
||||||
```
|
```
|
||||||
|
|
||||||
## Operation log
|
## Writes log
|
||||||
|
|
||||||
User's input in terminal can be found in logs. for example:
|
User's input in terminal can be found in logs. for example:
|
||||||
|
|
||||||
@ -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:12 [wlog] 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: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
|
## Development
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
func FormatOperationLog(line *[]byte) (log string) {
|
func FormatWriteLog(line *[]byte) (log string) {
|
||||||
ascii := map[byte]string{
|
ascii := map[byte]string{
|
||||||
0: "", //NUL
|
0: "NUL",
|
||||||
1: "SOH",
|
1: "SOH",
|
||||||
2: "STX",
|
2: "STX",
|
||||||
3: "ETX",
|
3: "ETX",
|
||||||
|
@ -194,7 +194,8 @@ func (wt *WebTTY) handleMasterReadEvent(data []byte, line *[]byte) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "failed to marshal arguments map")
|
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
|
*line = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user