21个稳定版本 (3个主要版本)
5.0.4+20240223 | 2024年3月5日 |
---|---|
3.1.0+20220225 | 2022年4月26日 |
3.0.0+20220225 | 2022年3月8日 |
2.0.4+20210325 | 2021年4月15日 |
1.0.2+20161206 | 2016年12月27日 |
#8 in #command-line-interface
445 每月下载量
5MB
62K SLoC
logging2
命令行界面(CLI)允许您从终端舒适地使用Google Logging服务的多数功能。
默认情况下,所有输出都打印到标准输出,但可以通过设置标志将其直接重定向到文件,而不依赖于shell的功能。错误将打印到标准错误,并导致程序退出代码不为零。
如果请求数据结构,这些将作为格式化的JSON返回,以便作为其他工具的输入使用。
有关Logging API的所有其他信息,请参阅官方文档网站。
安装和源代码
使用cargo安装命令行界面:
cargo install google-logging2-cli
使用方法
本文档是根据修订版20240223的Logging API生成的。CLI版本为5.0.4。
logging2 [options]
billing-accounts
exclusions-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
exclusions-delete <name> [-p <v>]... [-o <out>]
exclusions-get <name> [-p <v>]... [-o <out>]
exclusions-list <parent> [-p <v>]... [-o <out>]
exclusions-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
get-cmek-settings <name> [-p <v>]... [-o <out>]
get-settings <name> [-p <v>]... [-o <out>]
locations-buckets-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-create-async <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-delete <name> [-p <v>]... [-o <out>]
locations-buckets-get <name> [-p <v>]... [-o <out>]
locations-buckets-links-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-links-delete <name> [-p <v>]... [-o <out>]
locations-buckets-links-get <name> [-p <v>]... [-o <out>]
locations-buckets-links-list <parent> [-p <v>]... [-o <out>]
locations-buckets-list <parent> [-p <v>]... [-o <out>]
locations-buckets-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-undelete <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-update-async <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-views-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-views-delete <name> [-p <v>]... [-o <out>]
locations-buckets-views-get <name> [-p <v>]... [-o <out>]
locations-buckets-views-list <parent> [-p <v>]... [-o <out>]
locations-buckets-views-logs-list <parent> [-p <v>]... [-o <out>]
locations-buckets-views-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-get <name> [-p <v>]... [-o <out>]
locations-list <name> [-p <v>]... [-o <out>]
locations-operations-cancel <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-operations-get <name> [-p <v>]... [-o <out>]
locations-operations-list <name> [-p <v>]... [-o <out>]
locations-recent-queries-list <parent> [-p <v>]... [-o <out>]
locations-saved-queries-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-saved-queries-delete <name> [-p <v>]... [-o <out>]
locations-saved-queries-list <parent> [-p <v>]... [-o <out>]
logs-delete <log-name> [-p <v>]... [-o <out>]
logs-list <parent> [-p <v>]... [-o <out>]
sinks-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
sinks-delete <sink-name> [-p <v>]... [-o <out>]
sinks-get <sink-name> [-p <v>]... [-o <out>]
sinks-list <parent> [-p <v>]... [-o <out>]
sinks-patch <sink-name> (-r <kv>)... [-p <v>]... [-o <out>]
sinks-update <sink-name> (-r <kv>)... [-p <v>]... [-o <out>]
entries
copy (-r <kv>)... [-p <v>]... [-o <out>]
list (-r <kv>)... [-p <v>]... [-o <out>]
tail (-r <kv>)... [-p <v>]... [-o <out>]
write (-r <kv>)... [-p <v>]... [-o <out>]
exclusions
create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
delete <name> [-p <v>]... [-o <out>]
get <name> [-p <v>]... [-o <out>]
list <parent> [-p <v>]... [-o <out>]
patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
folders
exclusions-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
exclusions-delete <name> [-p <v>]... [-o <out>]
exclusions-get <name> [-p <v>]... [-o <out>]
exclusions-list <parent> [-p <v>]... [-o <out>]
exclusions-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
get-cmek-settings <name> [-p <v>]... [-o <out>]
get-settings <name> [-p <v>]... [-o <out>]
locations-buckets-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-create-async <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-delete <name> [-p <v>]... [-o <out>]
locations-buckets-get <name> [-p <v>]... [-o <out>]
locations-buckets-links-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-links-delete <name> [-p <v>]... [-o <out>]
locations-buckets-links-get <name> [-p <v>]... [-o <out>]
locations-buckets-links-list <parent> [-p <v>]... [-o <out>]
locations-buckets-list <parent> [-p <v>]... [-o <out>]
locations-buckets-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-undelete <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-update-async <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-views-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-views-delete <name> [-p <v>]... [-o <out>]
locations-buckets-views-get <name> [-p <v>]... [-o <out>]
locations-buckets-views-list <parent> [-p <v>]... [-o <out>]
locations-buckets-views-logs-list <parent> [-p <v>]... [-o <out>]
locations-buckets-views-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-get <name> [-p <v>]... [-o <out>]
locations-list <name> [-p <v>]... [-o <out>]
locations-operations-cancel <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-operations-get <name> [-p <v>]... [-o <out>]
locations-operations-list <name> [-p <v>]... [-o <out>]
locations-recent-queries-list <parent> [-p <v>]... [-o <out>]
locations-saved-queries-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-saved-queries-delete <name> [-p <v>]... [-o <out>]
locations-saved-queries-list <parent> [-p <v>]... [-o <out>]
logs-delete <log-name> [-p <v>]... [-o <out>]
logs-list <parent> [-p <v>]... [-o <out>]
sinks-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
sinks-delete <sink-name> [-p <v>]... [-o <out>]
sinks-get <sink-name> [-p <v>]... [-o <out>]
sinks-list <parent> [-p <v>]... [-o <out>]
sinks-patch <sink-name> (-r <kv>)... [-p <v>]... [-o <out>]
sinks-update <sink-name> (-r <kv>)... [-p <v>]... [-o <out>]
update-settings <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations
buckets-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
buckets-create-async <parent> (-r <kv>)... [-p <v>]... [-o <out>]
buckets-delete <name> [-p <v>]... [-o <out>]
buckets-get <name> [-p <v>]... [-o <out>]
buckets-links-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
buckets-links-delete <name> [-p <v>]... [-o <out>]
buckets-links-get <name> [-p <v>]... [-o <out>]
buckets-links-list <parent> [-p <v>]... [-o <out>]
buckets-list <parent> [-p <v>]... [-o <out>]
buckets-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
buckets-undelete <name> (-r <kv>)... [-p <v>]... [-o <out>]
buckets-update-async <name> (-r <kv>)... [-p <v>]... [-o <out>]
buckets-views-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
buckets-views-delete <name> [-p <v>]... [-o <out>]
buckets-views-get <name> [-p <v>]... [-o <out>]
buckets-views-list <parent> [-p <v>]... [-o <out>]
buckets-views-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
get <name> [-p <v>]... [-o <out>]
list <name> [-p <v>]... [-o <out>]
operations-cancel <name> (-r <kv>)... [-p <v>]... [-o <out>]
operations-get <name> [-p <v>]... [-o <out>]
operations-list <name> [-p <v>]... [-o <out>]
logs
delete <log-name> [-p <v>]... [-o <out>]
list <parent> [-p <v>]... [-o <out>]
methods
get-cmek-settings <name> [-p <v>]... [-o <out>]
get-settings <name> [-p <v>]... [-o <out>]
update-cmek-settings <name> (-r <kv>)... [-p <v>]... [-o <out>]
update-settings <name> (-r <kv>)... [-p <v>]... [-o <out>]
monitored-resource-descriptors
list [-p <v>]... [-o <out>]
organizations
exclusions-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
exclusions-delete <name> [-p <v>]... [-o <out>]
exclusions-get <name> [-p <v>]... [-o <out>]
exclusions-list <parent> [-p <v>]... [-o <out>]
exclusions-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
get-cmek-settings <name> [-p <v>]... [-o <out>]
get-settings <name> [-p <v>]... [-o <out>]
locations-buckets-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-create-async <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-delete <name> [-p <v>]... [-o <out>]
locations-buckets-get <name> [-p <v>]... [-o <out>]
locations-buckets-links-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-links-delete <name> [-p <v>]... [-o <out>]
locations-buckets-links-get <name> [-p <v>]... [-o <out>]
locations-buckets-links-list <parent> [-p <v>]... [-o <out>]
locations-buckets-list <parent> [-p <v>]... [-o <out>]
locations-buckets-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-undelete <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-update-async <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-views-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-views-delete <name> [-p <v>]... [-o <out>]
locations-buckets-views-get <name> [-p <v>]... [-o <out>]
locations-buckets-views-list <parent> [-p <v>]... [-o <out>]
locations-buckets-views-logs-list <parent> [-p <v>]... [-o <out>]
locations-buckets-views-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-get <name> [-p <v>]... [-o <out>]
locations-list <name> [-p <v>]... [-o <out>]
locations-operations-cancel <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-operations-get <name> [-p <v>]... [-o <out>]
locations-operations-list <name> [-p <v>]... [-o <out>]
locations-recent-queries-list <parent> [-p <v>]... [-o <out>]
locations-saved-queries-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-saved-queries-delete <name> [-p <v>]... [-o <out>]
locations-saved-queries-list <parent> [-p <v>]... [-o <out>]
logs-delete <log-name> [-p <v>]... [-o <out>]
logs-list <parent> [-p <v>]... [-o <out>]
sinks-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
sinks-delete <sink-name> [-p <v>]... [-o <out>]
sinks-get <sink-name> [-p <v>]... [-o <out>]
sinks-list <parent> [-p <v>]... [-o <out>]
sinks-patch <sink-name> (-r <kv>)... [-p <v>]... [-o <out>]
sinks-update <sink-name> (-r <kv>)... [-p <v>]... [-o <out>]
update-cmek-settings <name> (-r <kv>)... [-p <v>]... [-o <out>]
update-settings <name> (-r <kv>)... [-p <v>]... [-o <out>]
projects
exclusions-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
exclusions-delete <name> [-p <v>]... [-o <out>]
exclusions-get <name> [-p <v>]... [-o <out>]
exclusions-list <parent> [-p <v>]... [-o <out>]
exclusions-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
get-cmek-settings <name> [-p <v>]... [-o <out>]
get-settings <name> [-p <v>]... [-o <out>]
locations-buckets-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-create-async <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-delete <name> [-p <v>]... [-o <out>]
locations-buckets-get <name> [-p <v>]... [-o <out>]
locations-buckets-links-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-links-delete <name> [-p <v>]... [-o <out>]
locations-buckets-links-get <name> [-p <v>]... [-o <out>]
locations-buckets-links-list <parent> [-p <v>]... [-o <out>]
locations-buckets-list <parent> [-p <v>]... [-o <out>]
locations-buckets-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-undelete <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-update-async <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-views-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-buckets-views-delete <name> [-p <v>]... [-o <out>]
locations-buckets-views-get <name> [-p <v>]... [-o <out>]
locations-buckets-views-list <parent> [-p <v>]... [-o <out>]
locations-buckets-views-logs-list <parent> [-p <v>]... [-o <out>]
locations-buckets-views-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-get <name> [-p <v>]... [-o <out>]
locations-list <name> [-p <v>]... [-o <out>]
locations-operations-cancel <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-operations-get <name> [-p <v>]... [-o <out>]
locations-operations-list <name> [-p <v>]... [-o <out>]
locations-recent-queries-list <parent> [-p <v>]... [-o <out>]
locations-saved-queries-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-saved-queries-delete <name> [-p <v>]... [-o <out>]
locations-saved-queries-list <parent> [-p <v>]... [-o <out>]
logs-delete <log-name> [-p <v>]... [-o <out>]
logs-list <parent> [-p <v>]... [-o <out>]
metrics-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
metrics-delete <metric-name> [-p <v>]... [-o <out>]
metrics-get <metric-name> [-p <v>]... [-o <out>]
metrics-list <parent> [-p <v>]... [-o <out>]
metrics-update <metric-name> (-r <kv>)... [-p <v>]... [-o <out>]
sinks-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
sinks-delete <sink-name> [-p <v>]... [-o <out>]
sinks-get <sink-name> [-p <v>]... [-o <out>]
sinks-list <parent> [-p <v>]... [-o <out>]
sinks-patch <sink-name> (-r <kv>)... [-p <v>]... [-o <out>]
sinks-update <sink-name> (-r <kv>)... [-p <v>]... [-o <out>]
sinks
create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
delete <sink-name> [-p <v>]... [-o <out>]
get <sink-name> [-p <v>]... [-o <out>]
list <parent> [-p <v>]... [-o <out>]
update <sink-name> (-r <kv>)... [-p <v>]... [-o <out>]
logging2 --help
Configuration:
[--scope <url>]...
Specify the authentication a method should be executed in. Each scope
requires the user to grant this application permission to use it.
If unset, it defaults to the shortest scope url for a particular method.
--config-dir <folder>
A directory into which we will store our persistent data. Defaults to
a user-writable directory that we will create during the first invocation.
[default: ~/.google-service-cli]
配置
程序将所有持久数据存储在~/.google-service-cli
目录中的JSON文件中,文件名以logging2
开头。您可以使用--config-dir
标志在每次调用的基础上更改用于存储配置的目录。
以下段落提供了有关各种类型持久数据的更多信息。
身份验证
大多数API需要用户对请求进行身份验证。如果是这种情况,作用域确定授予的权限集。这些通常不超过只读或完全访问。
如果没有设置,系统将自动选择最小可行的作用域,例如,当调用只读方法时,它只会请求只读作用域。您可以使用--scope
标志直接指定作用域。所有适用的作用域在相应方法的CLI文档中都有记录。
首次使用作用域时,系统会要求用户授权。遵循CLI给出的说明进行授权或拒绝。
如果用户验证了作用域,则相应的信息将被存储在配置目录中的JSON格式,例如~/.google-service-cli/logging2-token-<scope-hash>.json
。无需手动管理这些令牌。
要撤销授权的验证,请参阅官方文档。
应用程序密钥
为了允许任何应用程序使用Google服务,需要使用Google开发者控制台进行注册。然后为应用程序逐个启用可能使用的API。大多数API可以免费使用,并且有每日配额。
为了在不强迫任何人注册自己的应用程序的情况下更舒适地使用CLI,CLI附带了一个默认的应用程序密钥,相应的进行了配置。这也意味着全球范围内的重用可能会耗尽每日配额。
您可以通过将您自己的密钥文件放在此位置来解决这个问题:~/.google-service-cli/logging2-secret.json
,假设为它启用了所需的logging API。此类密钥文件可以在Google开发者控制台的APIs & auth -> Credentials -> Download JSON中下载并直接使用。
有关如何设置Google项目和启用API的更多信息,请参阅官方文档。
调试
尽管CLI尽力提供可用的错误消息,但有时可能需要知道导致特定问题的确切原因。这是通过允许所有客户端-服务器通信以原样输出到标准错误来实现的。
使用--debug
标志将使用Debug
表示法将错误打印到标准错误。
您可以考虑将标准错误重定向到文件,以便于使用,例如logging2 --debug <resource> <method> [options] 2>debug.txt
。
依赖项
~19–31MB
~583K SLoC