Print last 10 log messages when executing `kappa <config> tail`
Showing
1 changed file
with
4 additions
and
1 deletions
... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
11 | # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | 11 | # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF |
12 | # ANY KIND, either express or implied. See the License for the specific | 12 | # ANY KIND, either express or implied. See the License for the specific |
13 | # language governing permissions and limitations under the License. | 13 | # language governing permissions and limitations under the License. |
14 | +from datetime import datetime | ||
14 | import logging | 15 | import logging |
15 | 16 | ||
16 | import click | 17 | import click |
... | @@ -56,7 +57,9 @@ def test(ctx): | ... | @@ -56,7 +57,9 @@ def test(ctx): |
56 | def tail(ctx): | 57 | def tail(ctx): |
57 | context = Context(ctx.obj['config'], ctx.obj['debug']) | 58 | context = Context(ctx.obj['config'], ctx.obj['debug']) |
58 | click.echo('tailing logs...') | 59 | click.echo('tailing logs...') |
59 | - context.tail() | 60 | + for e in context.tail()[-10:]: |
61 | + ts = datetime.utcfromtimestamp(e['timestamp']//1000).isoformat() | ||
62 | + click.echo("{}: {}".format(ts, e['message'])) | ||
60 | click.echo('...done') | 63 | click.echo('...done') |
61 | 64 | ||
62 | @cli.command() | 65 | @cli.command() | ... | ... |
-
Please register or login to post a comment