作者 庄敏学

增加日志输出

  1 +2022/11/10 09:28:21.494 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "company" ("id" bigserial, "logo" text, "name" text, "charge_user_ids" jsonb, "status" bigint, "update_at" timestamptz, "create_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null
  2 +2022/11/10 09:28:21.521 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "department" ("id" bigserial, "company_id" bigint, "level" bigint, "name" text, "parent_id" bigint, "charge_user_ids" jsonb, "path" text, "create_at" timestamptz, "update_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null
  3 +2022/11/10 09:28:21.548 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "user" ("id" bigserial, "account" text, "avatar_url" text, "company_id" bigint, "admin_type" bigint, "name" text, "email" text, "status" bigint, "department_id" jsonb, "update_at" timestamptz, "create_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null
  4 +2022/11/10 09:28:21.575 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "received_message" ("message_id" bigserial, "message_type" text, "message_body" text, "occurred_on" timestamptz, "create_at" timestamptz, PRIMARY KEY ("message_id")) null
  5 +2022/11/10 09:28:21.602 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "role" ("id" bigserial, "name" text, "type" bigint, "description" text, "company_id" bigint, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null
  6 +2022/11/10 09:28:21.630 [D] [hook.go:130] performance COMMENT ON TABLE public."role" IS '角色'; null
  7 +2022/11/10 09:28:21.659 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".id IS 'ID'; null
  8 +2022/11/10 09:28:21.688 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".name IS '角色名称'; null
  9 +2022/11/10 09:28:21.716 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".type IS '角色类型(0角色可删、1系统预置角色不可删)'; null
  10 +2022/11/10 09:28:21.743 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".description IS '角色描述'; null
  11 +2022/11/10 09:28:21.771 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".company_id IS '公司ID'; null
  12 +2022/11/10 09:28:21.799 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".created_at IS '创建时间'; null
  13 +2022/11/10 09:28:21.828 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".updated_at IS '更新时间'; null
  14 +2022/11/10 09:28:21.856 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".deleted_at IS '删除时间'; null
  15 +2022/11/10 09:28:21.883 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "role_user" ("id" bigserial, "role_id" bigint, "user_id" bigint, "company_id" bigint, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null
  16 +2022/11/10 09:28:21.911 [D] [hook.go:130] performance COMMENT ON TABLE public."role_user" IS '角色用户关系'; null
  17 +2022/11/10 09:28:21.937 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".id IS 'ID'; null
  18 +2022/11/10 09:28:21.964 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".role_id IS '角色ID'; null
  19 +2022/11/10 09:28:21.993 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".user_id IS '用户ID'; null
  20 +2022/11/10 09:28:22.020 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".company_id IS '公司ID'; null
  21 +2022/11/10 09:28:22.047 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".created_at IS '创建时间'; null
  22 +2022/11/10 09:28:22.075 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".updated_at IS '更新时间'; null
  23 +2022/11/10 09:28:22.102 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".deleted_at IS '删除时间'; null
  24 +2022/11/10 09:28:22.116 [I] [???:0] performance http server Running on http://:8082
  25 +2022/11/10 09:28:22.860 [E] [asm_amd64.s:1594] performance kafka: client has run out of available brokers to talk to (Is your cluster reachable?) []
  26 +2022/11/10 09:29:54.845 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "company" ("id" bigserial, "logo" text, "name" text, "charge_user_ids" jsonb, "status" bigint, "update_at" timestamptz, "create_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null
  27 +2022/11/10 09:29:54.873 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "department" ("id" bigserial, "company_id" bigint, "level" bigint, "name" text, "parent_id" bigint, "charge_user_ids" jsonb, "path" text, "create_at" timestamptz, "update_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null
  28 +2022/11/10 09:29:54.899 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "user" ("id" bigserial, "account" text, "avatar_url" text, "company_id" bigint, "admin_type" bigint, "name" text, "email" text, "status" bigint, "department_id" jsonb, "update_at" timestamptz, "create_at" timestamptz, "delete_at" timestamptz, PRIMARY KEY ("id")) null
  29 +2022/11/10 09:29:54.926 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "received_message" ("message_id" bigserial, "message_type" text, "message_body" text, "occurred_on" timestamptz, "create_at" timestamptz, PRIMARY KEY ("message_id")) null
  30 +2022/11/10 09:29:54.953 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "role" ("id" bigserial, "name" text, "type" bigint, "description" text, "company_id" bigint, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null
  31 +2022/11/10 09:29:54.981 [D] [hook.go:130] performance COMMENT ON TABLE public."role" IS '角色'; null
  32 +2022/11/10 09:29:55.009 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".id IS 'ID'; null
  33 +2022/11/10 09:29:55.037 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".name IS '角色名称'; null
  34 +2022/11/10 09:29:55.068 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".type IS '角色类型(0角色可删、1系统预置角色不可删)'; null
  35 +2022/11/10 09:29:55.094 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".description IS '角色描述'; null
  36 +2022/11/10 09:29:55.121 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".company_id IS '公司ID'; null
  37 +2022/11/10 09:29:55.149 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".created_at IS '创建时间'; null
  38 +2022/11/10 09:29:55.183 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".updated_at IS '更新时间'; null
  39 +2022/11/10 09:29:55.212 [D] [hook.go:130] performance COMMENT ON COLUMN public."role".deleted_at IS '删除时间'; null
  40 +2022/11/10 09:29:55.243 [D] [hook.go:130] performance CREATE TABLE IF NOT EXISTS "role_user" ("id" bigserial, "role_id" bigint, "user_id" bigint, "company_id" bigint, "created_at" timestamptz, "updated_at" timestamptz, "deleted_at" timestamptz, PRIMARY KEY ("id")) null
  41 +2022/11/10 09:29:55.270 [D] [hook.go:130] performance COMMENT ON TABLE public."role_user" IS '角色用户关系'; null
  42 +2022/11/10 09:29:55.297 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".id IS 'ID'; null
  43 +2022/11/10 09:29:55.324 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".role_id IS '角色ID'; null
  44 +2022/11/10 09:29:55.351 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".user_id IS '用户ID'; null
  45 +2022/11/10 09:29:55.377 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".company_id IS '公司ID'; null
  46 +2022/11/10 09:29:55.403 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".created_at IS '创建时间'; null
  47 +2022/11/10 09:29:55.430 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".updated_at IS '更新时间'; null
  48 +2022/11/10 09:29:55.456 [D] [hook.go:130] performance COMMENT ON COLUMN public."role_user".deleted_at IS '删除时间'; null
  49 +2022/11/10 09:29:55.466 [I] [???:0] performance http server Running on http://:8082
  50 +2022/11/10 09:29:56.217 [E] [asm_amd64.s:1594] performance kafka: client has run out of available brokers to talk to (Is your cluster reachable?) []
  51 +2022/11/10 09:30:15.476 [D] [router.go:977] performance | 127.0.0.1| 200 | 364.534µs| match| GET  /log r:/log
  52 +2022/11/10 09:30:15.546 [D] [router.go:977] performance | 127.0.0.1| 404 | 959.763µs| nomatch| GET  /favicon.ico
不能预览此文件类型
  1 +package controllers
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/server/web"
  5 + "os"
  6 +)
  7 +
  8 +type LoggerController struct {
  9 + web.Controller
  10 +}
  11 +
  12 +func (controller *LoggerController) Output() {
  13 + bytes, _ := os.ReadFile("./debug.log")
  14 + controller.Ctx.WriteString(string(bytes))
  15 +}
  1 +package routers
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/server/web"
  5 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers"
  6 +)
  7 +
  8 +func init() {
  9 + //日志输出
  10 + web.Router("/log", &controllers.LoggerController{}, "Get:Output")
  11 +}