Skip to content

enhancement request: Display a specified number of log lines on console based on tail option #8232

@rahulmlokurte

Description

@rahulmlokurte

Is there an existing issue for this?

  • I have searched the existing issues

Enhancement description

The localstack logs command currently displays the complete logs. The --follow option can be used to stream the log output to the console in real time. However, sometimes it's not necessary to see the entire log file, and it would be useful to be able to display only a specific number of log lines.

The proposed enhancement is to add a new --tail option to the localstack logs command. This option will allow users to specify the number of lines they want to see from the log file. For example, localstack logs --tail 10 would display the last 10 lines of the log file.

This feature would be useful in situations where users only need to see a specific part of the log file, without having to scroll through the entire log output. It would make it easier to find the relevant information and help users save time.

Overall, adding the --tail option to the localstack logs command would be a valuable addition to the tool and improve the user experience.

🧑‍💻 Implementation

To implement the --tail option in the localstack logs command, we can modify the existing cmd_logs function in the
localstack.py file. The tail option will be passed as an argument to this function.

Note that this implementation will work even if the --follow option is used

Anything else?

Current Behaviour:

localstack git:(master) ✗ localstack logs
2023-05-01T12:29:10.880 DEBUG --- [  MainThread] plugin.manager             : instantiating plugin PluginSpec(localstack.hooks.on_infra_ready.do_run_state_load_all = <function do_run_state_load_all at 0x7f3673be7250>)
2023-05-01T12:29:10.880 DEBUG --- [  MainThread] plugin.manager             : plugin localstack.hooks.on_infra_ready:do_run_state_load_all is disabled
2023-05-01T12:29:18.853 DEBUG --- [   asgi_gw_0] l.aws.serving.wsgi         : GET localhost:4566/_localstack/health

Enhanced Behaviour:

localstack git:(master) ✗ localstack logs --tail 1
2023-05-01T12:29:18.853 DEBUG --- [   asgi_gw_0] l.aws.serving.wsgi         : GET localhost:4566/_localstack/health

Metadata

Metadata

Assignees

Labels

area: cliLocalStack CLItype: featureNew feature, or improvement to an existing feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions