(fmt=None, maxlen=None, **params)
| 448 | info = dict(datetime=now.isoformat(), timestamp=datetime_to_timestamp(now), code=0) |
| 449 | |
| 450 | def output(fmt=None, maxlen=None, **params): |
| 451 | raw = params.pop('raw', None) |
| 452 | if raw_output: |
| 453 | if raw is not None: |
| 454 | click.echo(raw) |
| 455 | elif json_output: |
| 456 | info.update(params) |
| 457 | else: |
| 458 | if fmt is not None: |
| 459 | msg = fmt.format(**params) |
| 460 | else: |
| 461 | # logfmt-like output |
| 462 | msg = ' '.join(f'{k}={v}' for k,v in params.items()) |
| 463 | if maxlen is not None: |
| 464 | msg = strtrunc(msg, maxlen) |
| 465 | click.echo(msg) |
| 466 | |
| 467 | def flush(): |
| 468 | if json_output and not raw_output: |
no test coverage detected