Skip to content

Commit

Permalink
add example of splitting logs into each line
Browse files Browse the repository at this point in the history
  • Loading branch information
wjo1212 committed Jan 23, 2018
1 parent 14f8a2f commit cb90a19
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* [Parameter Validation](#parameter-validation)
* [Output](#output)
* [Filter output](#filter-output)
* [Further Process](#further-process)
* [Command Reference](#command-reference)
* [Command Specification](#command-specification)
* [Alias](#alias)
Expand Down Expand Up @@ -237,7 +238,7 @@ the content in file `get_logs.json` as below. Note: the `\` is unnecessary to es

1. For operations like Create, Update and Delete, there's no output except the exit code is 0 which means success.

2. For operations like Get and List, it will output in json format.
2. For operations like Get and List, it will output in **json** format.

3. For errors, it will report in json format as below:

Expand Down Expand Up @@ -280,6 +281,22 @@ Then you will be the name list of second logstore and later ones as below:
["logstore1", "logstore2"]
```

### Further Process
You may want to process the output using your own cmd. For example, if you may want to break the logs into each line.
you could append thd command with a `|` on linux/unix:

```shell
| python2 -c "from __future__ import print_function;import json;map(lambda x: print(json.dumps(x).encode('utf8')), json.loads(raw_input()));"
or
| python3 -c "import json;list(map(lambda x: print(json.dumps(x)), json.loads(input())));"
```

e.g.
```shell
aliyun log get_log .... | | python2 -c "from __future__ import print_function;import json;map(lambda x: print(json.dumps(x).encode('utf8')), json.loads(raw_input()));" >> data.txt
```


## Command Reference

### Command Specification
Expand Down
18 changes: 18 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* [参数校验](#参数校验)
* [输出](#输出)
* [输出过滤](#输出过滤)
* [进一步处理](#进一步处理)
* [命令参考](#命令参考)
* [命令规范](#命令规范)
* [命令别名](#命令别名)
Expand Down Expand Up @@ -280,6 +281,23 @@ region-endpoint=cn-hangzhou.log.aliyuncs.com
["logstore1", "logstore2"]
```


<h2 id="进一步处理">进一步处理</h2>
某些情况下, 你需要使用其他命令进行处理, 例如需要把json格式的日志, 分行打印. 在Linux/Unix下, 你可以在命令后通过添加一个`|`来进一步处理.

```shell
| python2 -c "from __future__ import print_function;import json;map(lambda x: print(json.dumps(x).encode('utf8')), json.loads(raw_input()));"
or
| python3 -c "import json;list(map(lambda x: print(json.dumps(x)), json.loads(input())));"
```

例如:

```shell
aliyun log get_log .... | | python2 -c "from __future__ import print_function;import json;map(lambda x: print(json.dumps(x).encode('utf8')), json.loads(raw_input()));" >> data.txt
```


<h1 id="命令参考">命令参考</h1>

<h2 id="命令规范">命令规范</h2>
Expand Down

0 comments on commit cb90a19

Please sign in to comment.