Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

本地配置了appid和appkey后无日志上报到后台 #3

Closed
xiaojue opened this issue May 21, 2018 · 11 comments
Closed

本地配置了appid和appkey后无日志上报到后台 #3

xiaojue opened this issue May 21, 2018 · 11 comments

Comments

@xiaojue
Copy link

xiaojue commented May 21, 2018

本地在examples/framework/config.js中配置了 this.appid,this.appkey,但是在应用后台,刷新本地服务,使用node TSW 启动的demo,后台无数据展示。

是使用方法不对咩?

@bgdsh
Copy link

bgdsh commented May 21, 2018

围观一下。果然是一个不断自我提升的前端工程师。

@xiaojue
Copy link
Author

xiaojue commented May 21, 2018

debug了一下,在util/auto-report/logReport.js 下的91行,key是空,几个方法都debug了一直是空,所以导致上报失败了.

@xiaojue
Copy link
Author

xiaojue commented May 21, 2018

[DBUG] [37444 cpu0 1] [null] [logReport.js:130] report nothing: undefined 文档也没写。。这个key咋配置。
auto-report看起来是失败了。

@RobinzZH
Copy link
Collaborator

请求抓包需要配置染色才能生效,并没有全量上报
染色号码可使用alphaFile配置(https://tswjs.org/doc/api/config)
如果是使用开放平台,可到官网项目详情页、测试环境配置当天生效的临时染色
ps: 用户染色uid逻辑可以通过配置extendMod重新定义uid实现(https://tswjs.org/doc/api/config)
或者在业务逻辑开始时,手动使用日志接口设置logger.setKey(uid)

@xiaojue
Copy link
Author

xiaojue commented May 21, 2018

@RobinzZH 收到,我研究一下。

@xiaojue
Copy link
Author

xiaojue commented May 21, 2018

@RobinzZH 我在本地创建了alphaFile文件,增加了我在开放平台的测试id,然后我在express的demo里增加了setKey(uid);
看日志是上报了:

2018-05-21 14:46:44.056 [INFO] [38641 cpu 0] [null] [master.js:350] start worker....
2018-05-21 14:46:44.179 [INFO] [38641 cpuX 0] [null] [http.proxy.js:248] pid:38641 createServer ok
2018-05-21 14:46:44.181 [INFO] [38641 cpuX 0] [null] [http.proxy.js:556] isWindows, start litening
2018-05-21 14:46:44.191 [INFO] [38641 cpu0 0] [null] [http.proxy.js:441] cpu: 0, beforeStartup...
2018-05-21 14:46:44.192 [INFO] [38641 cpu0 0] [null] [http.proxy.js:447] cpu: 0, listen...
2018-05-21 14:46:44.212 [INFO] [38641 cpu0 0] [null] [http.proxy.js:465] cpu: 0, listen http ok 0.0.0.0:80
2018-05-21 14:46:44.213 [INFO] [38641 cpu0 0] [null] [http.proxy.js:515] cpu: 0, listen http ok 0.0.0.0:12801
2018-05-21 14:46:44.214 [INFO] [38641 cpu0 0] [null] [http.proxy.js:474] start heart beat
2018-05-21 14:46:44.215 [INFO] [38641 cpu0 0] [null] [http.proxy.js:492] cpu: 0, afterStartup...
2018-05-21 14:46:47.380 [DBUG] [38641 cpu0 1] [null] [http.route.js:499] GET http://127.0.0.1/express
2018-05-21 14:46:47.381 [DBUG] [38641 cpu0 1] [null] [http.route.js:506] idc: sz, server ip: , tcp: 127.0.0.1:62088 > 127.0.0.1:80, client ip: 127.0.0.1, cpuUsed: 0
2018-05-21 14:46:47.383 [DBUG] [38641 cpu0 1] [express] [alpha.js:62] {}
2018-05-21 14:46:47.389 [DBUG] [38641 cpu0 1] [express] [alphaMap.js:85] update ok
2018-05-21 14:46:47.392 [DBUG] [38641 cpu0 1] [express] [http.route.js:579] node-v8.4.0, name: express, appid: tsw183
2018-05-21 14:46:47.596 [DBUG] [38641 cpu0 1] [express] [logger.js:128] setKey: xiaojue1234
2018-05-21 14:46:47.596 [DBUG] [38641 cpu0 1] [express] [alpha.js:62] {}
2018-05-21 14:46:47.597 [INFO] [38641 cpu0 1] [express] [express.js:9] test my log
2018-05-21 14:46:47.597 [DBUG] [38641 cpu0 1] [express] [alpha.js:62] {}
2018-05-21 14:46:47.597 [DBUG] [38641 cpu0 1] [express] [http.route.js:554] showLineNumber on
2018-05-21 14:46:47.598 [DBUG] [38641 cpu0 1] [express] [http.route.js:561] response 200
2018-05-21 14:46:47.606 [DBUG] [38641 cpu0 1] [express] [http.route.js:51] clear called
2018-05-21 14:46:47.607 [DBUG] [38641 cpu0 1] [express] [http.route.js:392] finish, statusCode: 200, cost: 229ms
2018-05-21 14:46:47.615 [DBUG] [38641 cpu0 1] [express] [logReport.js:107] xiaojue1234
2018-05-21 14:46:47.616 [DBUG] [38641 cpu0 1] [express] [alpha.js:62] {}
2018-05-21 14:46:47.616 [DBUG] [38641 cpu0 1] [express] [logReport.js:174] logType: alpha
2018-05-21 14:46:47.622 [DBUG] [38641 cpu0 1] [express] [logReport.js:190]
GET /express HTTP/1.1
host: 127.0.0.1
connection: keep-alive
cache-control: max-age=0
upgrade-insecure-requests: 1
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
accept-encoding: gzip, deflate, br
accept-language: zh-CN,zh;q=0.9,en;q=0.8,ja;q=0.7,zh-TW;q=0.6,it;q=0.5
tsw-trace-steps: 1


response 200 {
  "connection": "keep-alive",
  "keep-alive": "timeout=10",
  "x-powered-by": "Express",
  "server": "TSW/1.0.1445",
  "cache-control": "no-cache"
}
2018-05-21 14:46:47.624 [DBUG] [38641 cpu0 1] [express] [logReport.js:408] reportCloud
2018-05-21 14:46:47.624 [DBUG] [38641 cpu0 1] [express] [logReport.js:409] report log type: alpha, key xiaojue1234
2018-05-21 14:46:47.689 [DBUG] [38641 cpu0 1] [express] [ajax.js:303] [1] host from url: openapi.tswjs.org
2018-05-21 14:46:47.695 [DBUG] [38641 cpu0 1] [express] [ajax.js:529] [1] POST json ~ openapi.tswjs.org:443 https://openapi.tswjs.org/v1/log/report
2018-05-21 14:46:47.764 [DBUG] [38641 cpu0 1] [express] [capturer.js:60] [1] POST openapi.tswjs.org:443 ~ http://openapi.tswjs.org/v1/log/report
2018-05-21 14:46:47.769 [DBUG] [38641 cpu0 1] [express] [alpha.js:62] {}
2018-05-21 14:46:47.770 [DBUG] [38641 cpu0 1] [express] [capturer.js:71] [1] capture body on
2018-05-21 14:46:47.770 [DBUG] [38641 cpu0 1] [express] [capturer.js:60] [2] POST openapi.tswjs.org:443 ~ https://openapi.tswjs.org/v1/log/report
2018-05-21 14:46:47.771 [DBUG] [38641 cpu0 1] [express] [alpha.js:62] {}
2018-05-21 14:46:47.771 [DBUG] [38641 cpu0 1] [express] [capturer.js:71] [2] capture body on
2018-05-21 14:46:47.775 [DBUG] [38641 cpu0 1] [express] [Dns.hack.js:58] dns lookup: openapi.tswjs.org --> 58.247.214.103
2018-05-21 14:46:47.892 [DBUG] [38641 cpu0 1] [express] [capturer.js:79] [1] send finish, total size 3316
2018-05-21 14:46:47.892 [DBUG] [38641 cpu0 1] [express] [capturer.js:79] [2] send finish, total size 3316
2018-05-21 14:46:48.082 [DBUG] [38641 cpu0 1] [express] [capturer.js:153] [1] 10.222.22.208:62091 > 58.247.214.103:443 response 200 cost:318ms
2018-05-21 14:46:48.082 [DBUG] [38641 cpu0 1] [express] [capturer.js:153] [2] 10.222.22.208:62091 > 58.247.214.103:443 response 200 cost:312ms
2018-05-21 14:46:48.083 [DBUG] [38641 cpu0 1] [express] [ajax.js:760] [1] 58.247.214.103:443 response 200 cost:393ms
2018-05-21 14:46:48.085 [DBUG] [38641 cpu0 1] [express] [capturer.js:212] [1] end size:39, receive data cost: 321ms
2018-05-21 14:46:48.085 [DBUG] [38641 cpu0 1] [express] [capturer.js:212] [2] end size:39, receive data cost: 315ms
2018-05-21 14:46:48.086 [DBUG] [38641 cpu0 1] [express] [ajax.js:911] [1] end:39,	receive data cost: 2ms
2018-05-21 14:46:48.086 [DBUG] [38641 cpu0 1] [express] [ajax.js:938] [1] done size:39
2018-05-21 14:46:48.086 [DBUG] [38641 cpu0 1] [express] [ajax.js:989] [1] responseText:
{
  "code": 0,
  "message": "success"
}
2018-05-21 14:46:48.087 [DBUG] [38641 cpu0 1] [express] [ajax.js:433] [1] 返回码:0, isFail:0
2018-05-21 14:46:48.087 [DBUG] [38641 cpu0 1] [express] [logReport.js:442] reportCloud success.
2018-05-21 14:46:49.776 [DBUG] [38641 cpu0 1] [express] [http.route.js:78] clearing
2018-05-21 14:46:49.777 [DBUG] [38641 cpu0 0] [null] [http.route.js:101] cleared

但是我在开放平台里没找到对应的日志,我看的runtime里的所有日志。。

https://tsw183.tswjs.org/runtime/report

我也自己用logger.info 打印了一条日志,请问是在哪查看呢- -?

@xiaojue
Copy link
Author

xiaojue commented May 21, 2018

查看H5测试环境号码
xiaojue1234:alpha

app.all('/express',function(req, res){
  logger.setKey('xiaojue1234');
  logger.info('test my log');
  res.end('hello express~123211');
});

总觉得文档少了点啥。。

@xiaojue
Copy link
Author

xiaojue commented May 21, 2018

搞定,需要通过特殊的url访问才行。

@xiaojue xiaojue closed this as completed May 21, 2018
@xtx1130
Copy link

xtx1130 commented May 21, 2018

@xiaojue setKey(uid)这个uid是在这里配置的吗?

image
路径访问是类似:http://localhost:8081/hapi.js这样么?

@xiaojue
Copy link
Author

xiaojue commented May 21, 2018

@xtx1130 看到日志上报成功,需要根据这个url规则访问看日志结果:

查看实时日志
实时日志保留最新64条,滚动记录,24h过期
访问https://${appid}.tswjs.org/log/view/${UID}即可
appid -- 项目对应的appid
uid -- 对应染色的uid
权限范围 -- 项目成员

https://tswjs.org/guide/advance/logger

藏得有点深,名词基本靠猜- -

@xtx1130
Copy link

xtx1130 commented May 21, 2018

@xiaojue

四种方式可对UID染色:1.在config.alphaFile本地文件中声明

这里的意思是在根目录创建alphaFile文件还是在config中声明this.alphaFile,能不能把你的配置贴一下

RobinzZH added a commit that referenced this issue May 23, 2018
* 生成lcov格式覆盖率结果

* coveralls 支持

* only test js

* --recursive

* CI 加速

* bugfix

* 删除没有使用的变量

* 覆盖率测试去掉打印text-lcov

* update .gitignore

1. 只忽略顶层node_modules
2. 覆盖率测试打印下结果
huangyoukun pushed a commit that referenced this issue Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants