{"id":19640115,"url":"https://github.com/chimeejs/chimee-plugin-log","last_synced_at":"2026-06-06T21:32:00.922Z","repository":{"id":57197968,"uuid":"97221811","full_name":"Chimeejs/chimee-plugin-log","owner":"Chimeejs","description":"LogPlugin for chimee","archived":false,"fork":false,"pushed_at":"2018-11-07T14:48:53.000Z","size":124,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-24T22:01:47.380Z","etag":null,"topics":["chimee","plugin"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Chimeejs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-14T10:21:20.000Z","updated_at":"2017-11-17T10:02:46.000Z","dependencies_parsed_at":"2022-09-16T13:10:50.617Z","dependency_job_id":null,"html_url":"https://github.com/Chimeejs/chimee-plugin-log","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chimeejs%2Fchimee-plugin-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chimeejs%2Fchimee-plugin-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chimeejs%2Fchimee-plugin-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chimeejs%2Fchimee-plugin-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Chimeejs","download_url":"https://codeload.github.com/Chimeejs/chimee-plugin-log/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240947652,"owners_count":19883030,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chimee","plugin"],"created_at":"2024-11-11T14:04:42.686Z","updated_at":"2025-02-26T22:44:22.304Z","avatar_url":"https://github.com/Chimeejs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LogPlugin of Chimee\n\n实现日志输出及打点上报逻辑，可用于异常跟踪等。\n本插件继承自[popup插件](https://github.com/Chimeejs/chimee-plugin-popup)实现具备相应功能函数。\n\n## 默认菜单基本用法\n\n\u003e 使用默认日志输出，不做定制或修改。\n\n```javascript\nimport myLog from 'chimee-plugin-log';\nChimee.install(myLog);\nconst chimee = new Chimee({\n  wrapper: '#wrapper',\n  plugins: [myLog.name]\n});\n// 打开日志输出\nchimee[myLog.name].open();\n// 关闭日志输出\nchimee[myLog.name].close();\n```\n\u003e 提示：打开后才开始有日志输出到textarea中，所以如果想看完整日志，可以选择“下次自动打开”，然后保证下一次开启页面后能从初始化开始自动输出日志。\n\n效果示例：\n\n![](https://p2.ssl.qhimg.com/dr/600__/t01093aadbd9d752527.png)\n\n## 打点上报\n\u003e 通常我们需要将关键环节的日志信息上传到服务端，以生成观看报表、异常报表等数据分析内容。\n\u003e 你可以参考以下代码配置实现日志上报。\n\n```javascript\nimport myLog from 'chimee-plugin-log';\nChimee.install(myLog);\nconst chimee = new Chimee({\n  wrapper: '#wrapper',\n  plugins: [{\n    name: myLog.name,\n    // 告诉插件你有一个可以接受日志上报的服务端接口\n    logPostUrl: 'https://myDomain.xx/log_push'\n  }]\n});\n```\n这样默认的关键环节将自动上报日志到服务端，除了相应时长数据，包含以下基本数据信息：\n```\nref - location.href\npro - location.protocol\nbox - chimeeConfig.box\ntype - chimeeConfig.type\nsrc - chimeeConfig.src\nuid - 插件内部计算产生\nver - chimee 版本\nevt - 日志名称\n_t - 时间戳\n_r - 随机数\n```\n\n目前系统插件默认会执行打点上报的环节包含：`loadstart` `canplay` `ended` `playing` `pause` `waiting` `timeout` `error` `destroy`。\n其中的超时事件 `timeout` 对应默认等待载入时长 `logPlugin.timeoutDelay`，默认值为30000毫秒。\n\n如果你想增加其他事件环节的打点，可以像下面这样实现：\n```javascript\nimport myLog from 'chimee-plugin-log';\nChimee.install(myLog);\nconst chimee = new Chimee({\n  wrapper: '#wrapper',\n  plugins: [{\n    name: myLog.name,\n    // 告诉插件你有一个可以接受日志上报的服务端接口\n    logPostUrl: 'https://myDomain.xx/log_push',\n    events: {\n      play: () =\u003e {\n        this.sendLog('日志名称', { src: this.src, 'myData': '想要上报的数据' });\n      }\n    }\n  }]\n});\n```\n\n如果你需要对输出或上报的打点数据进行加工，可以像下面这样实现：\n```javascript\nimport myLog from 'chimee-plugin-log';\nChimee.install(myLog);\nconst chimee = new Chimee({\n  wrapper: '#wrapper',\n  plugins: [{\n    name: myLog.name,\n    // 告诉插件你有一个可以接受日志上报的服务端接口\n    logPostUrl: 'https://myDomain.xx/log_push',\n    methods: {\n      // 自定义loadstart环节输出日志包含的数据格式\n      write_loadstart_log: (evt, logData) =\u003e {\n        return Object.assign(logData, {\n          src: this.src,\n          'myData': '想要输出的数据'\n        });\n      },\n      // 自定义loadstart环节上报日志包含的数据格式\n      send_loadstart_log: (evt, logData) =\u003e {\n        return Object.assign(logData, {\n          src: this.src,\n          'myData': '想要上报的数据'\n        });\n      }\n    }\n  }]\n});\n```\n\n希望您用着方便，有相应问题请随时反馈。\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchimeejs%2Fchimee-plugin-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchimeejs%2Fchimee-plugin-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchimeejs%2Fchimee-plugin-log/lists"}