Merge pull request #11 from ryansb/fixTail
Print last 10 log messages when executing `kappa <config> tail`
Showing
1 changed file
with
9 additions
and
6 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 |
... | @@ -42,7 +43,7 @@ def deploy(ctx): | ... | @@ -42,7 +43,7 @@ def deploy(ctx): |
42 | click.echo('deploying...') | 43 | click.echo('deploying...') |
43 | context.deploy() | 44 | context.deploy() |
44 | click.echo('...done') | 45 | click.echo('...done') |
45 | - | 46 | + |
46 | @cli.command() | 47 | @cli.command() |
47 | @click.pass_context | 48 | @click.pass_context |
48 | def test(ctx): | 49 | def test(ctx): |
... | @@ -50,15 +51,17 @@ def test(ctx): | ... | @@ -50,15 +51,17 @@ def test(ctx): |
50 | click.echo('testing...') | 51 | click.echo('testing...') |
51 | context.test() | 52 | context.test() |
52 | click.echo('...done') | 53 | click.echo('...done') |
53 | - | 54 | + |
54 | @cli.command() | 55 | @cli.command() |
55 | @click.pass_context | 56 | @click.pass_context |
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() |
63 | @click.pass_context | 66 | @click.pass_context |
64 | def status(ctx): | 67 | def status(ctx): |
... | @@ -91,7 +94,7 @@ def status(ctx): | ... | @@ -91,7 +94,7 @@ def status(ctx): |
91 | click.echo(click.style(line, fg='green')) | 94 | click.echo(click.style(line, fg='green')) |
92 | else: | 95 | else: |
93 | click.echo(click.style(' None', fg='green')) | 96 | click.echo(click.style(' None', fg='green')) |
94 | - | 97 | + |
95 | @cli.command() | 98 | @cli.command() |
96 | @click.pass_context | 99 | @click.pass_context |
97 | def delete(ctx): | 100 | def delete(ctx): |
... | @@ -99,7 +102,7 @@ def delete(ctx): | ... | @@ -99,7 +102,7 @@ def delete(ctx): |
99 | click.echo('deleting...') | 102 | click.echo('deleting...') |
100 | context.delete() | 103 | context.delete() |
101 | click.echo('...done') | 104 | click.echo('...done') |
102 | - | 105 | + |
103 | @cli.command() | 106 | @cli.command() |
104 | @click.pass_context | 107 | @click.pass_context |
105 | def add_event_sources(ctx): | 108 | def add_event_sources(ctx): | ... | ... |
-
Please register or login to post a comment