# debug
[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) [![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers)
[![OpenCollective](https://opencollective.com/debug/sponsors/badge.svg)](#sponsors)
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
A tiny JavaScript debugging utility modelled after Node.js core's debugging
technique. Works in Node.js and web browsers.
## Installation
```bash
$ npm install debug
```
## Usage
`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole.
Example [_app.js_](./examples/node/app.js):
```js
var debug = require('debug')('http')
, http = require('http')
, name = 'My App';
// fake app
debug('booting %o', name);
http.createServer(function(req, res){
debug(req.method + ' ' + req.url);
res.end('hello\n');
}).listen(3000, function(){
debug('listening');
});
// fake worker of some kind
require('./worker');
```
Example [_worker.js_](./examples/node/worker.js):
```js
var a = require('debug')('worker:a')
, b = require('debug')('worker:b');
function work() {
a('doing lots of uninteresting work');
setTimeout(work, Math.random() * 1000);
}
work();
function workb() {
b('doing some work');
setTimeout(workb, Math.random() * 2000);
}
workb();
```
The `DEBUG` environment variable is then used to enable these based on space or
comma-delimited names.
Here are some examples:
<img width="647" alt="screen shot 2017-08-08 at 12 53 04 pm" src="https://user-images.githubusercontent.com/71256/29091703-a6302cdc-7c38-11e7-8304-7c0b3bc600cd.png">
<img width="647" alt="screen shot 2017-08-08 at 12 53 38 pm" src="https://user-images.githubusercontent.com/71256/29091700-a62a6888-7c38-11e7-800b-db911291ca2b.png">
<img width="647" alt="screen shot 2017-08-08 at 12 53 25 pm" src="https://user-images.githubusercontent.com/71256/29091701-a62ea114-7c38-11e7-826a-2692bedca740.png">
#### Windows note
On Windows the environment variable is set using the `set` command.
```cmd
set DEBUG=*,-not_this
```
Note that PowerShell uses different syntax to set environment variables.
```cmd
$env:DEBUG = "*,-not_this"
```
Then, run the program to be debugged as usual.
## Namespace Colors
Every debug instance has a color generated for it based on its namespace name.
This helps when visually parsing the debug output to identify which debug instance
a debug line belongs to.
#### Node.js
In Node.js, colors are enabled when stderr is a TTY. You also _should_ install
the [`supports-color`](https://npmjs.org/supports-color) module alongside debug,
otherwise debug will only use a small handful of basic colors.
<img width="521" src="https://user-images.githubusercontent.com/71256/29092181-47f6a9e6-7c3a-11e7-9a14-1928d8a711cd.png">
#### Web Browser
Colors are also enabled on "Web Inspectors" that understand the `%c` formatting
option. These are WebKit web inspectors, Firefox ([since version
31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/))
and the Firebug plugin for Firefox (any version).
<img width="524" src="https://user-images.githubusercontent.com/71256/29092033-b65f9f2e-7c39-11e7-8e32-f6f0d8e865c1.png">
## Millisecond diff
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below:
<img width="647" src="https://user-images.githubusercontent.com/71256/29091956-6bd78372-7c39-11e7-8c55-c948396d6edd.png">
## Conventions
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output.
## Wildcards
The `*` character may be used as a wildcard. Suppose for example your library has
debuggers named "connect:bodyParser", "connect:compress", "connect:session",
instead of listing all three with
`DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do
`DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
You can also exclude specific debuggers by prefixing them with a "-" character.
For example, `DEBUG=*,-connect:*` would include all debuggers except those
starting with "connect:".
## Environment Variables
When running through Node.js, you can set a few environment variables that will
change the behavior of the debug logging:
| Name | Purpose |
|-----------|-------------------------------------------------|
| `DEBUG` | Enables/disables specific debugging namespaces. |
| `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY). |
| `DEBUG_COLORS`| Whether or not to use colors in the debug output. |
| `DEBUG_DEPTH` | Object inspection depth. |
| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. |
__Note:__ The environment variables beginning with `DEBUG_` end up being
converted into an Options object that gets used with `%o`/`%O` formatters.
See the Node.js documentation for
[`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options)
for the complete list.
## Formatters
Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting.
Below are the officially supported formatters:
| Formatter | Representation |
|-----------|----------------|
| `%O` | Pretty-print an Object on multiple lines. |
| `%o` | Pretty-print an Object all on a single line. |
| `%s` | String. |
| `%d` | Number (both integer and float). |
| `%j` | JSON. Replaced with the string '[Circular]' if the argument contains circular references. |
| `%%` | Single percent sign ('%'). This does not consume an argument. |
### Custom formatters
You can add custom formatters by extending the `debug.formatters` object.
For example, if you wanted to add support for rendering a Buffer as hex with
`%h`, you could do something like:
```js
const createDebug = require('debug')
createDebug.formatters.h = (v) => {
return v.toString('hex')
}
// …elsewhere
const debug = createDebug('foo')
debug('this is hex: %h', new Buffer('hello world'))
// foo this is hex: 68656c6c6f20776f726c6421 +0ms
```
## Browser Support
You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify),
or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest),
if you don't want to build it yourself.
Debug's enable state is currently persisted by `localStorage`.
Consider the situation sh
没有合适的资源?快使用搜索试试~ 我知道了~
AiJ是一套完整的房间类游戏解决方案,支持无限水平扩展来满足更大的人数承载,并且提供了良好地调试接口
共3333个文件
js:1152个
ts:831个
png:450个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 150 浏览量
2023-06-26
09:16:58
上传
评论
收藏 28.42MB ZIP 举报
温馨提示
AiJ是一套完整的房间类游戏解决方案,支持无限水平扩展来满足更大的人数承载,并且提供了良好地调试接口,主要技术为Java、typescript 非常适合Java技术栈的同学入门游戏开发。主要模块包括:(注册中心。大厅服务。游戏服务。亲友圈服务。运营管理系统。CocosCreator游戏客户端)。网络协议使用Websocket,以更好的支持多平台需求,计划同时支持Mysql、Oracle、SqlServer、Postgresql、Sqlite等多种数据库。具有完整的机器人体系,机器人自动游戏,高智商游戏AI
资源推荐
资源详情
资源评论
收起资源包目录
AiJ是一套完整的房间类游戏解决方案,支持无限水平扩展来满足更大的人数承载,并且提供了良好地调试接口 (3333个子文件)
AUTHORS 321B
gradlew.bat 2KB
mahjong.bin 52KB
plaza.bin 26KB
commons.bin 7KB
welcome.bin 2KB
jsb_module_register.cpp 6KB
AppDelegate.cpp 3KB
main.cpp 2KB
main.cpp 2KB
main.cpp 1KB
index.css 414KB
waves.css 825B
.env.development 541B
.eslintignore 34B
.eslintrc 219B
AiJ-ui.fairy 132B
AiJGame.vcxproj.filters 1KB
aiJApp.fire 5KB
NumFont.fnt 659B
TimerFont.fnt 576B
NumFont.fnt 576B
401.gif 160KB
.gitignore 2KB
.gitignore 521B
.gitignore 91B
.gitignore 36B
build.gradle 5KB
build.gradle 586B
settings.gradle 248B
gradlew 5KB
AppDelegate.h 2KB
main.h 2KB
AppController.h 2KB
RootViewController.h 1KB
SDKWrapper.h 750B
SDKDelegate.h 699B
resource.h 475B
index.html 9KB
login.html 4KB
main.html 2KB
service.html 493B
plaza.html 489B
users.html 489B
room.html 487B
index.html 472B
index.html 124B
Icon.icns 700KB
favicon.ico 66KB
game.ico 47KB
shiro.ini 717B
gradle-wrapper.jar 49KB
MahjongTableAbility.java 41KB
MahjongRoomAiJTesterGui.java 35KB
Table.java 26KB
AiJStarter.java 20KB
TableAbility.java 12KB
UserService.java 8KB
PingHRule.java 8KB
MahjongKit.java 7KB
RoomAiJStarter.java 7KB
CoreConfig.java 6KB
HeroManager.java 6KB
AppActivity.java 6KB
SDKWrapper.java 6KB
RoomAiJTester.java 6KB
DatatableInjector.java 5KB
MahjongRoomAiJStarter.java 5KB
AiJMessageHandler.java 5KB
AiJPlatformConfig.java 5KB
PlazaAiJStarter.java 5KB
RoomRecordEventResponse.java 4KB
LruCache.java 4KB
TableManager.java 4KB
AiJRealm.java 4KB
PlayingGameSceneResponse.java 4KB
JUIManager.java 4KB
ZkPro.java 4KB
ServiceDetail.java 4KB
MahjongLogic.java 4KB
AiJDbPro.java 4KB
AiJDs.java 3KB
AiJPlatformStarter.java 3KB
RoomServiceEventHandler.java 3KB
RegistryCenter.java 3KB
Hero.java 3KB
AvatarController.java 3KB
LanHRule.java 3KB
SameColourHRule.java 3KB
Scoreboard.java 3KB
Pbkdf2.java 3KB
RechargeRecordEventResponse.java 3KB
RoleController.java 3KB
RoomRecordEventHandler.java 3KB
LoginEventHandler.java 3KB
WXEntryActivity.java 3KB
UserAssetTransEventHandler.java 3KB
DistributorController.java 3KB
HeroProfileEventResponse.java 3KB
LoginEventResponse.java 3KB
共 3333 条
- 1
- 2
- 3
- 4
- 5
- 6
- 34
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6656
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功