feature: Exeprefix support logformat or logger
zhangguanzhang opened this issue · comments
.
hi @zhangguanzhang
To avoid misunderstanding I would like to receive an accurate description about your proposal.
In case your idea is to have an out like the below one:
2021-02-22 07:54:23 Go-ansible example ──
2021-02-22 07:54:23 Go-ansible example ── PLAY [all] *********************************************************************
2021-02-22 07:54:23 Go-ansible example ──
2021-02-22 07:54:23 Go-ansible example ── TASK [Gathering Facts] *********************************************************
2021-02-22 07:54:23 Go-ansible example ── ok: [127.0.0.1]
2021-02-22 07:54:23 Go-ansible example ──
2021-02-22 07:54:23 Go-ansible example ── TASK [simple-ansibleplaybook] **************************************************
2021-02-22 07:54:23 Go-ansible example ── ok: [127.0.0.1] => {
2021-02-22 07:54:23 Go-ansible example ── "msg": "Your are running 'simple-ansibleplaybook' example"
2021-02-22 07:54:23 Go-ansible example ── }
2021-02-22 07:54:23 Go-ansible example ──
2021-02-22 07:54:23 Go-ansible example ── PLAY RECAP *********************************************************************
2021-02-22 07:54:23 Go-ansible example ── 127.0.0.1 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
2021-02-22 07:54:23 Go-ansible example ──
2021-02-22 07:54:23 Go-ansible example ── Playbook run took 0 days, 0 hours, 0 minutes, 0 seconds
You can write your ExecPrefix just like that:
layout := "2006-01-02 15:04:05"
playbook := &ansibler.AnsiblePlaybookCmd{
Playbook: "site.yml",
ConnectionOptions: ansiblePlaybookConnectionOptions,
Options: ansiblePlaybookOptions,
ExecPrefix: fmt.Sprintf("%s %s", time.Now().Format(layout), "Go-ansible example"),
}
If you would like to go further, just explain me a little bit more about what you have in mind.
Thanks a lot!
not the static string, like this
2021-02-22 07:54:23 Go-ansible example ──
2021-02-22 07:54:23 Go-ansible example ── PLAY [all] *********************************************************************
2021-02-22 07:54:24 Go-ansible example ──
2021-02-22 07:54:24 Go-ansible example ── TASK [Gathering Facts] *********************************************************
2021-02-22 07:54:24 Go-ansible example ── ok: [127.0.0.1]
2021-02-22 07:54:24 Go-ansible example ──
2021-02-22 07:54:25 Go-ansible example ── TASK [simple-ansibleplaybook] **************************************************
2021-02-22 07:54:25 Go-ansible example ── ok: [127.0.0.1] => {
2021-02-22 07:54:25 Go-ansible example ── "msg": "Your are running 'simple-ansibleplaybook' example"
2021-02-22 07:54:25 Go-ansible example ── }
2021-02-22 07:54:25 Go-ansible example ──
2021-02-22 07:54:26 Go-ansible example ── PLAY RECAP *********************************************************************
2021-02-22 07:54:26 Go-ansible example ── 127.0.0.1 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
2021-02-22 07:54:26 Go-ansible example ──
2021-02-22 07:54:26 Go-ansible example ── Playbook run took 0 days, 0 hours, 0 minutes, 0 seconds
@zhangguanzhang I am working on #40 It includes a new component named transformers which lets you to customize the outputs it will be ready on v1.0.0
nice work
@zhangguanzhang version 1.0.0 has been released and you can prepend a date time suffix using transformers
read the upgrade guide please