emicklei / gmig

Google Cloud Platform migrations tool for infrastructure-as-code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[IMPROVEMENT IDEA] Standardize logging

tkivisik opened this issue · comments

Date in ISO
Currently, status output starts with a timestamp (e.g. 2018/10/22 16:55:35). I propose the date be formatted in ISO format (i.e. 2018-10-22).

Column Separator to Tab
Currently, logging column separator is space ' ', which can also be found inside the columns themselves. This means cutting out columns (e.g. cut -d ' ' -f 1 gmig_log_file.txt) requires significant effort to get right. I propose the column separator be changed to '\t' which is the default separator in Bash cut and some other tools, and is unlikely to be part of a filename. Think of also using sort by not the first column - currently very tricky.

Filename
Currently, filename is written inside the parentheses. I propose it be turned into a column of it's own.

stdout instead of stderr
Currently, logs end up in stderr, not in stdout (where I expected it). That means, piping it into a as follows didn't work: gmig status project >> log.txt, but this worked gmig status project 2>> log.txt

these are good proposals. I realise people like to use the output for scripting. Let's make it easy for that purpose. What about the separators?

i started working on this using branch betterlogs. I decided to remove the whole pretty formatting of filenames.

Separators
In general, the delimiter should be unique in a sense that it can't be part of the filename or any other part of the log line. Only this way any meaningful data command like cut could be made to work.

I find one of the most useful Bash data commands to be cut. man cut shows that the default separator is tab, which also happens to be not present in any other part of the log line. Therefore, tab is a possible convenient delimiter which should be considered (if it's not dealt by the package you intent to use already).

@tkivisik i propose to close this. feel free to reopen if anybody is interested in this