# 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)
A tiny node.js debugging utility modelled after node core's debugging technique.
**Discussion around the V3 API is under way [here](https://github.com/visionmedia/debug/issues/370)**
## 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_:
```js
var debug = require('debug')('http')
, http = require('http')
, name = 'My App';
// fake app
debug('booting %s', 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_:
```js
var debug = require('debug')('worker');
setInterval(function(){
debug('doing some work');
}, 1000);
```
The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples:
![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png)
![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.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.
## 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.
![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png)
When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below:
![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.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".
## 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_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 shown below where you have `worker:a` and `worker:b`,
and wish to debug both. You can enable this using `localStorage.debug`:
```js
localStorage.debug = 'worker:*'
```
And then refresh the page.
```js
a = debug('worker:a');
b = debug('worker:b');
setInterval(function(){
a('doing some work');
}, 1000);
setInterval(function(){
b('doing some work');
}, 1200);
```
#### Web Inspector Colors
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).
Colored output looks something like:
![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png)
## Output streams
By default `debug` will log to stderr, however this can be configured per-namespace by overriding the `log` method:
Example _stdout.js_:
```js
var debug = require('debug');
var error = debug('app:error');
// by default stderr is used
error('goes to stderr!');
var log = debug('app:log');
// set this namespace to log via console.log
log.log = console.log.bind(console); // don't forget to bind to console!
log('goes to stdout');
error('still goes to stderr!');
// set all output to go via console.info
// overrides all per-namespace log settings
debug.log = console.info.bind(console);
error('now goes to stdout via console.info');
log('still goes to stdout, but via console.info now');
```
## Authors
- TJ Holowaychuk
- Nathan Rajlich
- Andrew Rhyne
## Backers
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/debug#backer)]
<a href="https://opencollective.com/debug/backer/0/website" target="_blank"><img src="https://opencollective.com/debug/backer/0/avatar.svg"></a>
<a href="https://opencollective.com/debug/backer/1/website" targ
没有合适的资源?快使用搜索试试~ 我知道了~
CharacterControls
共2307个文件
info:455个
meta:393个
json:169个
5星 · 超过95%的资源 需积分: 49 94 下载量 199 浏览量
2018-12-04
19:33:36
上传
评论 3
收藏 47.46MB ZIP 举报
温馨提示
Laya 摇杆控制 角色移动 Laya 摇杆控制 角色移动 https://blog.csdn.net/nicepainkiller/article/details/84797178 https://blog.csdn.net/nicepainkiller/article/details/84797178
资源推荐
资源详情
资源评论
收起资源包目录
CharacterControls (2307个子文件)
00000000000000001000000000000000 4KB
00000000000000002000000000000000 4KB
00000000000000003000000000000000 4KB
00000000000000004000000000000000 4KB
00000000000000004100000000000000 4KB
00000000000000005000000000000000 4KB
00000000000000005100000000000000 4KB
00000000000000006000000000000000 4KB
00000000000000006100000000000000 4KB
00000000000000007000000000000000 4KB
00000000000000007100000000000000 4KB
00000000000000008000000000000000 4KB
00000000000000009000000000000000 4KB
0000000000000000a000000000000000 4KB
0000000000000000a100000000000000 4KB
0000000000000000b000000000000000 4KB
0000000000000000c000000000000000 4KB
0007073e0d0b3aa4388f0c43ed0fac93 4KB
01236b44af1c31a43b16f853ff54e9f1 4KB
029c746c0748afa4086d08ae763b4a1e 4KB
02dbdb0cd4a89564aa06d889792ecef5 4KB
030bd5f78f5a021458ac923cd71a8684 4KB
03371386b1d8a3145a25004cf6b3ae62 4KB
055a7f064040c1947825d1efa4047e49 4KB
05853d1ac51141f4ba7ef4366ebdfb82 4KB
074703ce584e3724f89e3ab33a2b7ae7 4KB
07afb215e4dbf3d4989a77ac3010d318 4KB
083daa6cae381214c80c413ae48c76b5 4KB
086874b727c6f4843b82934c6fb14d6b 11KB
0880390380a035a4f9dcea8ccd9d41fa 4KB
09ee7e71a716b5c438b9dbe39dce3c52 4KB
0ae0204f3d0161844b44885111afe119 4KB
0ba2b0e3be59bf846bdca0d6613f032a 4KB
0d3781d8d7d4a7e4196fb235bae22cda 4KB
0d3bb855445e36e479c85976fc88383a 5KB
0d45ec7bf50e2584394fe539e91c0dc5 4KB
0d596c40274bc8343ac359b7fcc7900a 4KB
0ddd51cb08e71a3428b9f1e0f81a26fd 4KB
0dfda7de92dea1e46861da9d00828e5e 4KB
0e212e99998abcf43935cce750638886 4KB
0e7d5db042550b24eac41a10c8eeb9a4 4KB
0ea4b4731bcbfd94cbc179f171d60d42 4KB
0ee3b3f80767f8d4cb3478214331d6bb 4KB
10858855e9563714c96c1202ed4dbc87 4KB
1229d8a0d50a1f4499cc3f5a2720deee 4KB
12413dd97f6a7a149b48b881c4a5f4c7 4KB
12fd8a0055b84bb59e84c9835a37e333 6KB
135ee9c66d594e4469fe8fc01cdd26d7 4KB
13f75f0bfd8ee94419c2e8d7c091fb17 4KB
15e0a15befc5a654085c20cc0c1dc84d 4KB
16bca0175d0304c4fae90f94c99f7805 4KB
1706f4b2406716d42a338756e8170738 4KB
190a0ac062476c947abdc4177af69d4b 4KB
1962331a0147eee4dab72af38dd01c6f 4KB
19db947ed7efcd44686a114ade8dc21f 692KB
1a56e260d2ab111478971f0c4ebe8548 4KB
1aa4aa24bf35aa34da320a02fa447117 4KB
1b5c490f978dc5d4d98e3a8f43e425b0 10KB
1b80dab5091942042bc815dd84ed72e6 4KB
1bccf4bc6f7edc149bd7d8fb6d31b456 4KB
1be8926e03c9c1d44870c7ab000af0d7 4KB
1c6d1fbb51834b64847b1b73a75bfc77 7KB
1d460b877e006234cb3305a157c59f13 4KB
1d552e8ea8f62a7409e3b452c7f927af 4KB
1d7c7ae6b652b704bacc0977ff9dd4ec 4KB
1d98125fce69ff34c8a0e313d20c64f9 4KB
1daf83ed9a952e947a41ee89cca3e803 108KB
1de1e68514495d0459f5cc8abc1f10f6 4KB
207b17eecb95f2a4fabbc885bec4c067 4KB
215d9cc39f7f5cb469bf7c0cdfd0bdab 4KB
2163c0f4fa82fe84a8a4be25fbeb17fa 4KB
2190ff2b38108d14389da9fad7a34505 41KB
21eff446d50eaf44a85985cd4c0b6fa1 5KB
221a93d2f792af6499601f6e687bb13c 4KB
22aac37be7501ca48adda39ac554ec70 4KB
22bbff84521dad64eb1e879a6fad0b76 4KB
22d8e4b68c224fc4b9d21cb461b5db7e 4KB
230415ca952687448b8e97c9ceb6f732 4KB
239714b36abe5544591689b25273e7fc 4KB
24135ca50887b0b49a1c63708e1eaaf8 4KB
2517a41c22a84bf45a01fb1d5875b29d 4KB
25fc8954a678fa94cb17bb37f12d3150 4KB
267a216ec4216634d85a5a93b5245060 4KB
2682a692a2be7e14e901a738c7806da0 5KB
269316eca79215043a548f419b018ef8 4KB
26d91e19255333a4bbb9eb2016455ef4 4KB
28d7a0e317ec0b041a5e33561920b47a 4KB
293e853b3fe1d534d9fc8e941da7a700 4KB
2a2aff953ed347f4da1be57ebbb13a12 4KB
2aae2e6833e5fe9419a1ca73dfa9e24b 4KB
2b570b85f09b1464598bc72888bd2650 4KB
2c82a335321db714494dd424014a6930 4KB
2d32f52505199c24ba0e93681c0cd7c8 4KB
2e18561322c3e044b9f26294a2a02de2 4KB
2e497587226b8294db59f93c66bc1d6c 4KB
2f6b4c9fe6727a94cb56ca6153d49b40 4KB
2f9866815255bf144b0dcca4c4a668af 4KB
2fe3476eabbbb6c448e6b55a2cc471f5 5KB
3034a6a227321c94ba325bd11e3b597b 4KB
307433eba81a469ab1e2084d52d1a5a2 5KB
共 2307 条
- 1
- 2
- 3
- 4
- 5
- 6
- 24
资源评论
- 欧北里斯的巨神兵2019-07-31参考参考一下
- chengchengbox2020-08-21可用,但是是个ts的,我要找js的
坎大哈
- 粉丝: 8455
- 资源: 76
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功