Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log user's writes in the TTY #57

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Conversation

llaoj
Copy link

@llaoj llaoj commented Nov 15, 2022

Sometimes, we want see the operations log in the terminal when enabled -w.

Write log

If you set --write-log option, user's writes in the TTY can be Logged. for example:

if you run gotty like this:

./gotty -w --write-log --permit-arguments ./test.sh

this is test.sh:

#!/bin/bash

echo "Welcome: $4"
kubectl -n $1 exec -it $2 -c $3 -- sh

visit http://127.0.0.1:8080/?arg=without-istio&arg=sleep-7b6d569576-57sjq&arg=sleep&arg=21001713 and input your commands in shell, and you will see user's writes in the log (operation logs):

...
2022/11/13 10:48:12 [write-log] {"arg":["without-istio","sleep-7b6d569576-57sjq","sleep","21001713"]} lsCR
2022/11/13 10:48:14 [write-log] {"arg":["without-istio","sleep-7b6d569576-57sjq","sleep","21001713"]} pwdCR
...

Using the [write-log] flag, you can collect and store these logs persistently. All args are in the log, including the userID.

Copy link
Owner

@sorenisanerd sorenisanerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Just a few things to address :)

webtty/webtty.go Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
utils/log.go Outdated Show resolved Hide resolved
utils/log.go Show resolved Hide resolved
utils/log.go Outdated Show resolved Hide resolved
utils/log.go Show resolved Hide resolved
utils/log.go Outdated Show resolved Hide resolved
webtty/webtty.go Outdated Show resolved Hide resolved
webtty/webtty.go Outdated Show resolved Hide resolved
webtty/webtty.go Outdated Show resolved Hide resolved
@llaoj
Copy link
Author

llaoj commented Nov 29, 2022

Great suggestion! I'll make some changes and submit.

@llaoj
Copy link
Author

llaoj commented Dec 11, 2022

@sorenisanerd Thanks for your suggestion, I made some changes, please review again.

@llaoj llaoj changed the title add writes logs in stdout Log user's writes in the TTY Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants