Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iwask/69706eccad503a6292dd2c917cd1a377 to your computer and use it in GitHub Desktop.
Save iwask/69706eccad503a6292dd2c917cd1a377 to your computer and use it in GitHub Desktop.

Hexabase CLI によるActionScriptのログ取得方法

What is the hexabase-cli?

hexabase-cli is a command line tool to manupulate Hexabase resource and services.

インストール

$ npm install -g hexabase-cli

環境設定

アクセスする環境を設定します

アクセス環境はcontextと呼ばれる単位で管理されます。 ここでは、利用している開発環境を指定し、stgと命名します。

server: API Server URL sse: eventServer URL  <-- server からの通知を受け取るためのPub/Sub providerです。

$ hx contexts:set stg --server=https://az-api.hexabase.com --sse=https://az-sse.hexabase.com

以下のコマンドで正しく設定されていることを確認します。

$ hx contexts:get 
NAME           SERVER                        SSE
stg            https://az-api.hexabase.com   https://az-sse.hexabase.com

ログイン

$ hx contexts:login

ダイアログ質問に答えていき、ログインします。

? Enter your email » h.iwasaki@b-eee.com
? Enter your password » xxxxx
Successfully logged in as: h.iwasaki@b-eee.com

ActionScriptコマンドとログの購読

ActionScriptの画面を開きます。

画面中のデータのu_id, p_id を組み合わせてサブスクライブchannelを指定します。

USAGE:  
hx logs:actionscript CHANNEL #CHANNEL format = logs_<u_id>_<p_id>

ログの購読開始

$ hx logs:actionscript logs_5afeb66813ac8000078354c7_5f52598ae2fb440001214119
Listening for logs...

ActionScript内で利用可能なloggerオブジェクト

ActionScript内にて、以下5種類のログ出力関数を利用できます

function main(data) {
    logger.debug("debug....");
    logger.info("some info");
    logger.debug("warning!");
    logger.error("ERROR!!!");
    logger.log("---- log output ---");
}

「試行」を押下すると、 CLIコンソール内に、以下のようにログが出力されます

[DEBUG] debug....
[INFO] some info
[DEBUG] warning!
[ERROR] ERROR!!!
---- log output ---

その他補足事項

  • ログの購読は、「試行」ボタン押下時のみ、確認できます。APIからの実行やアクション実行時にはログは出力されません。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment