Skip to content

Commit

Permalink
👌 IMPROVE: Enable phpmyadmin and DEBUG_LOCAL_SQL by default (#320)
Browse files Browse the repository at this point in the history
```
2022-09-24 09:06:04,812 INFO 1793 [-/127.0.0.1/10567ea0-3ba5-11ed-a8c6-6f52da8076ba/2.946ms GET /foo] [Tracing] auth: 0, npm-command: -, referer: -, user-agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
[sql-debug] [20.193ms] SELECT * FROM `packages` WHERE `scope` = '' AND `name` = 'foo' LIMIT 1
```

![image](https://user-images.githubusercontent.com/156269/192073800-dc5dd934-6f81-4868-a0c6-778e6111d402.png)
  • Loading branch information
fengmk2 authored Sep 24, 2022
1 parent b91a550 commit 35e7d3a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $ npm install
$ MYSQL_DATABASE=cnpmcore npm run prepare-database

# 启动 Web 服务
$ DEBUG_LOCAL_SQL=true npm run dev
$ npm run dev

# 访问
curl -v http://127.0.0.1:7001
Expand Down
2 changes: 1 addition & 1 deletion config/config.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default (appInfo: EggAppConfig) => {
config.orm.logger = {
// TODO: try to save SQL log into ctx logger or app logger
logQuery(sql: string, duration: number) {
console.log('[%sms] %s', duration, sql);
console.log('[sql-debug] [%sms] %s', duration, sql);
},
};
}
Expand Down
30 changes: 15 additions & 15 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ services:
- cnpm

# database explorer
# phpmyadmin:
# image: phpmyadmin
# restart: always
# environment:
# MYSQL_ROOT_PASSWORD:
# MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
# MYSQL_USER: user
# MYSQL_PASSWORD: pass
# PMA_HOST: 'mysql'
# ports:
# - 8080:80
# networks:
# - cnpm
# depends_on:
# - mysql
phpmyadmin:
image: phpmyadmin
restart: always
environment:
MYSQL_ROOT_PASSWORD:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_USER: user
MYSQL_PASSWORD: pass
PMA_HOST: 'mysql'
ports:
- 8080:80
networks:
- cnpm
depends_on:
- mysql

volumes:
cnpm-redis:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"scripts": {
"contributor": "git-contributor",
"dev": "egg-bin dev",
"dev": "DEBUG_LOCAL_SQL=true egg-bin dev",
"debug": "egg-bin debug",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
Expand Down

0 comments on commit 35e7d3a

Please sign in to comment.