-
Notifications
You must be signed in to change notification settings - Fork 15
tcm: show TCM logs #1168
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
base: master
Are you sure you want to change the base?
tcm: show TCM logs #1168
Conversation
66584c4
to
d2cdeb3
Compare
Added support for showing TCM logs @TarantoolBot Title: Added support for showing TCM logs This commit introduces the ability to view TCM logs using the `tt tcm log` command. This command works in couple with the `tt tcm start` command, and show the logs of the TCM process that was running by it. Command expect exists `tcm.log` file in the current directory. **Usage example:** ```bash tt tcm log --lines 100 --follow ``` This command will show the last 100 lines of the TCM log file and continue to follow the log output. This feature is useful for monitoring the TCM process. Without the `--follow` flag, it will show the last 100 lines of the log file and exit. The command also supports following flags: - `--no-color` to disable colored output - `--no-format` to disable structured output **Possible output:** ```text { time: **2025-05-29T17:19:47.905335965+03:00** level: INFO msg: _tcm stopped_ source: { file: "tcm/internal/app/tcm/server/server.go", function: "tcm/internal/server.(*TcmAPI).Close", line: 175 } } { time: **2025-05-29T17:19:47.90451709+03:00** level: WARN msg: _retrying of unary invoker failed_ attempt: 0, error: "rpc error: code = Canceled desc = latest balancer error: last connection error: connection error: desc = \"transport: Error while dialing: dial tcp 127.0.0.1:2379: connect: connection refused\"", source: { file: "go.etcd.io/etcd/client/v3@v3.5.15/retry_interceptor.go", function: "v3.(*Client).unaryClientInterceptor.func1", line: 63 }, target: "etcd-endpoints://0xc0003d2000/127.0.0.1:2379" } { time: **2025-05-29T17:19:47.90548212+03:00** level: ERROR msg: _fail to get entity from etcd_ err: "context canceled", path: "/cluster/", source: { file: "tcm/internal/app/tcm/server.go", function: "tcm/internal/app/tcm/server.(*TcmAPI).validationKV", line: 17 } } ``` Closes #TNTP-1103 PreCommit-Verified: Passed
d2cdeb3
to
7d82ab4
Compare
//! "VERBOSE|ALARM" => ERROR fail to unmarshal log level | ||
//? "--log.default.level=VERBOSE", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not get the comment. Please describe it with more context.
"github.com/tarantool/tt/cli/tail" | ||
) | ||
|
||
const LogFileName = "tcm.log" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it required to be public?
const LogFileName = "tcm.log" | |
const logFileName = "tcm.log" |
// FollowLogs reads the last `lines` lines from the log file and prints them. | ||
// It continues to follow the log file, printing new lines as they are added. | ||
func FollowLogs(lines uint, prt LogPrinter) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a test for the call.
// PrintLogs reads the last `lines` lines from the log file and prints them. | ||
func PrintLogs(lines uint, prt LogPrinter) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a test for the call.
// Format formats a log string, applying colors and indentation if necessary. | ||
// If noFormat is true or the string is not a valid JSON object, it returns | ||
// the string as is without any formatting. | ||
func (f *logPrinter) Format(str string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why if f
- log or printer...
func (f *logPrinter) Format(str string) string { | |
func (l *logPrinter) Format(str string) string { |
func (f *logPrinter) Format(str string) string { | |
func (p *logPrinter) Format(str string) string { |
// LogPrinter is an interface for printing formatted log messages. | ||
type LogPrinter interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// LogPrinter is an interface for printing formatted log messages. | |
type LogPrinter interface { | |
// Printer is an interface for printing formatted log messages. | |
type Printer interface { |
// NewLogFormatter creates a new log printer with optional formatting and coloring. | ||
func NewLogFormatter(noFormat, noColor bool, out io.Writer) *logPrinter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NewLogFormatted creates a logPrinter?
Why the call is public?
@@ -0,0 +1,60 @@ | |||
package tcm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to test a public API.
package tcm | |
package tcm_test |
// Logging contains configuration for displaying TCM logs. | ||
type Logging struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SomethingOpts is usual naming for the stuff.
// Logging contains configuration for displaying TCM logs. | |
type Logging struct { | |
// LoggerOpts contains configuration for displaying TCM logs. | |
type LoggerOpts struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add a Changelog entry.
Added support for showing TCM logs
This commit introduces the ability to view TCM logs using
the
tt tcm log
command.This command works in couple with the
tt tcm start
command,and show the logs of the TCM process that was running by it.
Command expect exists
tcm.log
file in the current directory.Usage example:
This command will show the last 100 lines of the TCM log
file and continue to follow the log output.
This feature is useful for monitoring the TCM process.
Without the
--follow
flag, it will show the last 100 linesof the log file and exit.
The command also supports following flags:
--no-color
to disable colored output--no-format
to disable structured outputExpand to possible output:
I didn't forget about (remove if it is not applicable):
Related issues:
Closes #TNTP-1103