@tachybase/plugin-log-viewer 1.3.21 → 1.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.js +2 -2
- package/dist/externalVersion.js +5 -6
- package/dist/node_modules/tar-fs/package.json +1 -1
- package/dist/server/plugin.d.ts +1 -1
- package/dist/server/plugin.js +1 -1
- package/dist/server/resourcer/logger.d.ts +1 -1
- package/dist/server/resourcer/logger.js +12 -12
- package/package.json +9 -14
package/dist/client/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(e,
|
|
1
|
+
(function(e,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("@tachybase/client"),require("react-i18next"),require("react/jsx-runtime"),require("react"),require("@ant-design/icons"),require("@tego/client"),require("ahooks"),require("antd")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react-i18next","react/jsx-runtime","react","@ant-design/icons","@tego/client","ahooks","antd"],r):(e=typeof globalThis!="undefined"?globalThis:e||self,r(e["@tachybase/plugin-log-viewer"]={},e["@tachybase/client"],e["react-i18next"],e.jsxRuntime,e.react,e["@ant-design/icons"],e["@tego/client"],e.ahooks,e.antd))})(this,function(e,r,l,t,a,v,C,w,i){"use strict";var se=Object.defineProperty,ne=Object.defineProperties;var oe=Object.getOwnPropertyDescriptors;var Q=Object.getOwnPropertySymbols;var ie=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var J=(e,r,l)=>r in e?se(e,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[r]=l,_=(e,r)=>{for(var l in r||(r={}))ie.call(r,l)&&J(e,l,r[l]);if(Q)for(var l of Q(r))le.call(r,l)&&J(e,l,r[l]);return e},j=(e,r)=>ne(e,oe(r));var W=(e,r,l)=>new Promise((t,a)=>{var v=i=>{try{w(l.next(i))}catch(f){a(f)}},C=i=>{try{w(l.throw(i))}catch(f){a(f)}},w=i=>i.done?t(i.value):Promise.resolve(i.value).then(v,C);w((l=l.apply(e,r)).next())});const f="log-viewer";function X(p){return r.i18n.t(p,{ns:[f,"core"]})}function I(){return l.useTranslation([f,"core"])}const{Paragraph:L,Text:E}=i.Typography,B=a.memo(()=>{const{t:p}=I();return t.jsxs(i.Typography,{children:[t.jsxs(L,{children:[t.jsx(E,{code:!0,children:"[app]/request_*.log"})," - ",p("API request and response logs")]}),t.jsxs(L,{children:[t.jsx(E,{code:!0,children:"[app]/system_*.log"})," -"," ",p("Application, database, plugins and other system logs, the error level logs will be sent to")," ",t.jsx(E,{code:!0,children:"[app]/system_error_*.log"})]}),t.jsxs(L,{children:[t.jsx(E,{code:!0,children:"[app]/sql_*.log"})," -"," ",p("SQL execution logs, printed by Sequelize when the db logging is enabled")]})]})});B.displayName="Tips";const O=a.memo(p=>{const{token:g}=i.theme.useToken(),{t:y}=I(),x=w.useMemoizedFn(y),k=r.useAPIClient(),[T,m]=a.useState(["0"]),[b,Y]=a.useState(""),[Z,D]=a.useState(!0),[$,F]=a.useState([]),[q,H]=a.useState(),{data:K}=r.useRequest(()=>k.resource("logger").list().then(o=>{var d;return(d=o.data)==null?void 0:d.data})),{data:A,run:R}=r.useRequest({url:"logger:preview",method:"post",data:{file:q}},{manual:!0});a.useEffect(()=>{q&&R()},[q]);const M=a.useCallback((o,d)=>o.map((n,u)=>{const s=`${d}-${u}`;return typeof n=="string"?{title:n,key:s,icon:t.jsx(v.FileOutlined,{})}:{title:n.name,key:s,icon:t.jsx(v.FolderOutlined,{}),children:M(n.files,s)}}),[]),S=a.useMemo(()=>{const o=K||[];return[{title:x("All"),key:"0",children:M(o,"0")}]},[K,M,x]),ee=o=>{m(o),D(!1)},te=o=>{const{value:d}=o.target,n=s=>s.reduce((c,h)=>{var P;return(P=h.title)!=null&&P.includes(d)&&c.push(h),h.children?[...c,...n(h.children)]:c},[]),u=n(S).map(s=>s.key);m(u),Y(d),D(!0),F([])},N=a.useMemo(()=>{if(!b)return S;const o=d=>{const n=[];for(const u of d){const s=u.title,c=s.indexOf(b),h=s.substring(0,c),P=s.substring(c+b.length),U=c>-1?t.jsxs("span",{children:[h,t.jsx("span",{style:{color:g.colorPrimary},children:b}),P]}):t.jsx("span",{children:s});if(c>-1)n.push(j(_({},u),{title:U}));else if(u.children){const G=o(u.children);G.length&&n.push(j(_({},u),{title:U,children:G}))}}return n};return o(S)},[b,S,g.colorPrimary]),re=()=>{const o=(n,u)=>n.reduce((s,c)=>{let h=c.title;return h=c.key==="0"?h:`${u}/${h}`,c.children?[...s,...o(c.children,c.key==="0"?"":h)]:($.includes(c.key)&&c.key!=="0"&&s.push(h),s)},[]),d=o(S,"");d.length&&k.request({url:"logger:download",method:"post",responseType:"blob",data:{files:d}}).then(n=>{const u=window.URL.createObjectURL(new Blob([n.data],{type:"application/gzip"})),s=document.createElement("a");s.setAttribute("href",u),s.setAttribute("download","logs.tar.gz"),s.click(),s.remove()}).catch(n=>{console.log(n)})};return t.jsxs(i.Card,{style:{minHeight:"700px"},children:[t.jsx(i.Alert,{message:"",description:t.jsx(B,{}),type:"info",showIcon:!0}),t.jsx(i.Input.Search,{style:{marginTop:16,width:"450px"},placeholder:x("Search"),onChange:te}),t.jsxs("div",{className:r.css`
|
|
2
2
|
display: flex;
|
|
3
|
-
`,children:[
|
|
3
|
+
`,children:[t.jsx("div",{style:{maxHeight:"400px",width:"450px",overflow:"auto",border:"1px solid",marginTop:"6px",marginBottom:"10px",borderColor:g.colorBorder},children:N.length?t.jsx(i.Tree,{checkable:!0,showIcon:!0,showLine:!0,checkedKeys:$,expandedKeys:T,autoExpandParent:Z,onExpand:ee,onCheck:o=>F(o),treeData:N,selectable:!0,onSelect:(o,d)=>{if(!d.node.children){const n=V(N,o[0],0,"");H(n||void 0)}}}):t.jsx(i.Empty,{image:i.Empty.PRESENTED_IMAGE_SIMPLE})}),t.jsx("div",{style:{maxHeight:"400px",overflow:"auto",border:"1px solid",marginTop:"6px",marginBottom:"10px",borderColor:g.colorBorder,width:"1005px",marginLeft:"10px"},children:q?t.jsx(C.CodeMirror,{value:A==null?void 0:A.data,width:"1000px",height:"398px"}):null})]}),t.jsxs(i.Button,{type:"primary",onClick:re,children:[x("Download")," (.tar.gz)"]})]})});O.displayName="LogsDownloader";const V=(p,g,y,x)=>{const k=g.split("-"),T=k[y];let m=x;if(y>0&&(m+=`/${p[T].title}`),y===k.length-1)return m;if(p[T].children)return V(p[T].children,g,y+1,m)};class z extends r.Plugin{load(){return W(this,null,function*(){this.app.systemSettingsManager.add("system-services.log-viewer",{title:X("Log Viewer"),icon:"FileTextOutlined",Component:O,aclSnippet:"pm.system-services.log-viewer"})})}}e.PluginLogViewer=z,e.default=z,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.3.1",
|
|
3
|
-
"@tachybase/client": "1.3.
|
|
4
|
-
"@ant-design/icons": "5.
|
|
3
|
+
"@tachybase/client": "1.3.22",
|
|
4
|
+
"@ant-design/icons": "5.6.1",
|
|
5
|
+
"@tego/client": "1.3.39",
|
|
5
6
|
"ahooks": "3.9.0",
|
|
6
7
|
"antd": "5.22.5",
|
|
7
|
-
"@
|
|
8
|
-
"react-i18next": "15.2.0"
|
|
9
|
-
"@tachybase/actions": "1.3.21",
|
|
10
|
-
"@tachybase/logger": "1.3.21"
|
|
8
|
+
"@tego/server": "1.3.39",
|
|
9
|
+
"react-i18next": "15.2.0"
|
|
11
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"tar-fs","version":"3.1.0","description":"filesystem bindings for tar-stream","dependencies":{"pump":"^3.0.0","tar-stream":"^3.1.5"},"optionalDependencies":{"bare-fs":"^4.0.1","bare-path":"^3.0.0"},"imports":{"fs":{"bare":"bare-fs","default":"fs"},"path":{"bare":"bare-path","default":"path"}},"files":["index.js"],"standard":{"ignore":["test/fixtures/**"]},"keywords":["tar","fs","file","tarball","directory","stream"],"devDependencies":{"brittle":"^3.1.3","rimraf":"^2.6.3","standard":"^17.0.1"},"scripts":{"test":"standard && brittle test/index.js"},"bugs":{"url":"https://github.com/mafintosh/tar-fs/issues"},"homepage":"https://github.com/mafintosh/tar-fs","main":"index.js","directories":{"test":"test"},"author":"Mathias Buus","license":"MIT","repository":{"type":"git","url":"https://github.com/mafintosh/tar-fs.git"},"_lastModified":"2025-07-
|
|
1
|
+
{"name":"tar-fs","version":"3.1.0","description":"filesystem bindings for tar-stream","dependencies":{"pump":"^3.0.0","tar-stream":"^3.1.5"},"optionalDependencies":{"bare-fs":"^4.0.1","bare-path":"^3.0.0"},"imports":{"fs":{"bare":"bare-fs","default":"fs"},"path":{"bare":"bare-path","default":"path"}},"files":["index.js"],"standard":{"ignore":["test/fixtures/**"]},"keywords":["tar","fs","file","tarball","directory","stream"],"devDependencies":{"brittle":"^3.1.3","rimraf":"^2.6.3","standard":"^17.0.1"},"scripts":{"test":"standard && brittle test/index.js"},"bugs":{"url":"https://github.com/mafintosh/tar-fs/issues"},"homepage":"https://github.com/mafintosh/tar-fs","main":"index.js","directories":{"test":"test"},"author":"Mathias Buus","license":"MIT","repository":{"type":"git","url":"https://github.com/mafintosh/tar-fs.git"},"_lastModified":"2025-07-29T06:19:51.614Z"}
|
package/dist/server/plugin.d.ts
CHANGED
package/dist/server/plugin.js
CHANGED
|
@@ -31,7 +31,7 @@ __export(plugin_exports, {
|
|
|
31
31
|
default: () => plugin_default
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(plugin_exports);
|
|
34
|
-
var import_server = require("@
|
|
34
|
+
var import_server = require("@tego/server");
|
|
35
35
|
var import_logger = __toESM(require("./resourcer/logger"));
|
|
36
36
|
class PluginLogViewerServer extends import_server.Plugin {
|
|
37
37
|
afterAdd() {
|
|
@@ -30,17 +30,17 @@ __export(logger_exports, {
|
|
|
30
30
|
default: () => logger_default
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(logger_exports);
|
|
33
|
-
var import_promises = require("fs/promises");
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
33
|
+
var import_promises = require("node:fs/promises");
|
|
34
|
+
var import_node_path = require("node:path");
|
|
35
|
+
var import_node_stream = __toESM(require("node:stream"));
|
|
36
|
+
var import_node_zlib = __toESM(require("node:zlib"));
|
|
37
|
+
var import_server = require("@tego/server");
|
|
38
38
|
var import_tar_fs = require("tar-fs");
|
|
39
39
|
const tarFiles = (files) => {
|
|
40
40
|
return new Promise((resolve, reject) => {
|
|
41
|
-
const passthrough = new
|
|
42
|
-
const gz =
|
|
43
|
-
(0, import_tar_fs.pack)((0,
|
|
41
|
+
const passthrough = new import_node_stream.default.PassThrough();
|
|
42
|
+
const gz = import_node_zlib.default.createGzip();
|
|
43
|
+
(0, import_tar_fs.pack)((0, import_server.getLoggerFilePath)(), {
|
|
44
44
|
entries: files
|
|
45
45
|
}).on("data", (chunk) => {
|
|
46
46
|
passthrough.write(chunk);
|
|
@@ -64,7 +64,7 @@ var logger_default = {
|
|
|
64
64
|
if (!appName) {
|
|
65
65
|
ctx.throw(400, ctx.t("App not found"));
|
|
66
66
|
}
|
|
67
|
-
const path = (0,
|
|
67
|
+
const path = (0, import_server.getLoggerFilePath)();
|
|
68
68
|
const readDir = async (path2, hasPermission) => {
|
|
69
69
|
const fileTree = [];
|
|
70
70
|
try {
|
|
@@ -75,7 +75,7 @@ var logger_default = {
|
|
|
75
75
|
if (hasSubDirPermission === void 0) {
|
|
76
76
|
hasSubDirPermission = appName === "main" || file.name === appName;
|
|
77
77
|
}
|
|
78
|
-
const subFiles = await readDir((0,
|
|
78
|
+
const subFiles = await readDir((0, import_node_path.join)(path2, file.name), hasSubDirPermission);
|
|
79
79
|
if (!subFiles.length) {
|
|
80
80
|
continue;
|
|
81
81
|
}
|
|
@@ -145,8 +145,8 @@ var logger_default = {
|
|
|
145
145
|
ctx.throw(401, ctx.t("Permission denied"));
|
|
146
146
|
}
|
|
147
147
|
try {
|
|
148
|
-
const path = (0,
|
|
149
|
-
ctx.body = await (0, import_promises.readFile)((0,
|
|
148
|
+
const path = (0, import_server.getLoggerFilePath)();
|
|
149
|
+
ctx.body = await (0, import_promises.readFile)((0, import_node_path.join)(path, file), { encoding: "utf8" });
|
|
150
150
|
} catch (err) {
|
|
151
151
|
ctx.log.error(`preview error: ${err.message}`, { file, err: err.stack });
|
|
152
152
|
ctx.throw(500, ctx.t("Preview logs failed."));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/plugin-log-viewer",
|
|
3
3
|
"displayName": "Logger",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.22",
|
|
5
5
|
"description": "Server-side logs, mainly including API request logs and system runtime logs, and allows to package and download log files.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Logging and monitoring"
|
|
@@ -10,23 +10,18 @@
|
|
|
10
10
|
"main": "dist/server/index.js",
|
|
11
11
|
"dependencies": {},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@ant-design/icons": "^5.
|
|
13
|
+
"@ant-design/icons": "^5.6.1",
|
|
14
|
+
"@tachybase/test": "^1.3.39",
|
|
15
|
+
"@tego/client": "^1.3.39",
|
|
16
|
+
"@tego/server": "^1.3.39",
|
|
14
17
|
"@types/tar-fs": "^2.0.4",
|
|
15
18
|
"ahooks": "^3.9.0",
|
|
16
19
|
"antd": "5.22.5",
|
|
17
|
-
"react-i18next": "
|
|
18
|
-
"tar-fs": "^3.1.0"
|
|
19
|
-
|
|
20
|
-
"peerDependencies": {
|
|
21
|
-
"@tachybase/actions": "1.3.21",
|
|
22
|
-
"@tachybase/test": "1.3.21",
|
|
23
|
-
"@tachybase/client": "1.3.21",
|
|
24
|
-
"@tachybase/logger": "1.3.21",
|
|
25
|
-
"@tachybase/server": "1.3.21"
|
|
20
|
+
"react-i18next": "15.2.0",
|
|
21
|
+
"tar-fs": "^3.1.0",
|
|
22
|
+
"@tachybase/client": "1.3.22"
|
|
26
23
|
},
|
|
27
24
|
"description.zh-CN": "服务端日志,主要包括接口请求日志和系统运行日志,并支持打包和下载日志文件。",
|
|
28
25
|
"displayName.zh-CN": "日志",
|
|
29
|
-
"scripts": {
|
|
30
|
-
"build": "tachybase-build --no-dts @tachybase/plugin-log-viewer"
|
|
31
|
-
}
|
|
26
|
+
"scripts": {}
|
|
32
27
|
}
|