Permalink
Browse files

update restify and bunyan to latest release versions

  • Loading branch information...
1 parent 635faf4 commit e75502ae451d0958f403a73f2315fabc4ab28527 @trentm committed Mar 28, 2012
Showing with 8,188 additions and 13,988 deletions.
  1. +92 −7 node_modules/bunyan/CHANGES.md
  2. +32 −1 node_modules/bunyan/Makefile
  3. +38 −32 node_modules/bunyan/README.md
  4. +16 −9 node_modules/bunyan/TODO.md
  5. +342 −64 node_modules/bunyan/bin/bunyan
  6. +14 −0 node_modules/bunyan/foo.js
  7. +93 −46 node_modules/bunyan/lib/bunyan.js
  8. +26 −4 node_modules/bunyan/package.json
  9. +130 −0 node_modules/bunyan/test/cli.test.js
  10. +89 −0 node_modules/bunyan/test/ctor.test.js
  11. +53 −0 node_modules/bunyan/test/log.test.js
  12. +926 −0 node_modules/bunyan/tools/jsstyle
  13. +6 −8 node_modules/bunyan/tools/timechild.js
  14. +4 −5 node_modules/bunyan/tools/timeguard.js
  15. +6 −6 node_modules/bunyan/tools/timesrc.js
  16. +0 −6 node_modules/restify/.dir-locals.el
  17. +10 −5 node_modules/restify/.npmignore
  18. +54 −1 node_modules/restify/CHANGES.md
  19. +0 −98 node_modules/restify/Makefile
  20. +78 −1 node_modules/restify/README.md
  21. +0 −1,327 node_modules/restify/docs/guide.md
  22. +0 −199 node_modules/restify/examples/demo.js
  23. +0 −17 node_modules/restify/examples/handler-timing.d
  24. +104 −34 node_modules/restify/lib/clients/http_client.js
  25. +1 −1 node_modules/restify/lib/clients/index.js
  26. +11 −12 node_modules/restify/lib/clients/json_client.js
  27. +16 −16 node_modules/restify/lib/clients/string_client.js
  28. +7 −10 node_modules/restify/lib/errors/http_error.js
  29. +3 −3 node_modules/restify/lib/errors/index.js
  30. +8 −5 node_modules/restify/lib/errors/rest_error.js
  31. +34 −15 node_modules/restify/lib/index.js
  32. +3 −3 node_modules/restify/lib/plugins/accept.js
  33. +77 −0 node_modules/restify/lib/plugins/audit.js
  34. +6 −2 node_modules/restify/lib/plugins/authorization.js
  35. +5 −1 node_modules/restify/lib/plugins/body_parser.js
  36. +23 −17 node_modules/restify/lib/plugins/conditional_request.js
  37. +3 −3 node_modules/restify/lib/plugins/date.js
  38. +7 −7 node_modules/restify/lib/plugins/form_body_parser.js
  39. +2 −2 node_modules/restify/lib/plugins/index.js
  40. +7 −7 node_modules/restify/lib/plugins/json_body_parser.js
  41. +67 −0 node_modules/restify/lib/plugins/multipart_parser.js
  42. +8 −8 node_modules/restify/lib/plugins/query.js
  43. +55 −12 node_modules/restify/lib/plugins/throttle.js
  44. +55 −45 node_modules/restify/lib/request.js
  45. +90 −61 node_modules/restify/lib/response.js
  46. +32 −26 node_modules/restify/lib/route.js
  47. +138 −76 node_modules/restify/lib/server.js
  48. +0 −1 node_modules/restify/node_modules/.bin/bunyan
  49. +4 −0 node_modules/restify/node_modules/async/.npmignore
  50. +8 −4 node_modules/restify/node_modules/async/Makefile
  51. +22 −9 node_modules/restify/node_modules/async/README.md
  52. +0 −70 node_modules/restify/node_modules/async/deps/nodeunit.css
  53. +0 −1,966 node_modules/restify/node_modules/async/deps/nodeunit.js
  54. +19 −17 node_modules/restify/node_modules/async/lib/async.js
  55. +0 −4 node_modules/restify/node_modules/async/nodelint.cfg
  56. +43 −14 node_modules/restify/node_modules/async/package.json
  57. +0 −1,577 node_modules/restify/node_modules/async/test/test-async.js
  58. +0 −24 node_modules/restify/node_modules/async/test/test.html
  59. +0 −4 node_modules/restify/node_modules/bunyan/.npmignore
  60. +0 −2 node_modules/restify/node_modules/bunyan/AUTHORS.txt
  61. +0 −92 node_modules/restify/node_modules/bunyan/CHANGES.md
  62. +0 −12 node_modules/restify/node_modules/bunyan/Makefile
  63. +0 −406 node_modules/restify/node_modules/bunyan/README.md
  64. +0 −57 node_modules/restify/node_modules/bunyan/TODO.md
  65. +0 −457 node_modules/restify/node_modules/bunyan/bin/bunyan
  66. +0 −56 node_modules/restify/node_modules/bunyan/examples/err.js
  67. +0 −33 node_modules/restify/node_modules/bunyan/examples/hi.js
  68. +0 −47 node_modules/restify/node_modules/bunyan/examples/level.js
  69. +0 −20 node_modules/restify/node_modules/bunyan/examples/multi.js
  70. +0 −61 node_modules/restify/node_modules/bunyan/examples/server.js
  71. +0 −26 node_modules/restify/node_modules/bunyan/examples/src.js
  72. +0 −13 node_modules/restify/node_modules/bunyan/examples/unstringifyable.js
  73. +0 −910 node_modules/restify/node_modules/bunyan/lib/bunyan.js
  74. +0 −16 node_modules/restify/node_modules/bunyan/package.json
  75. +0 −2 node_modules/restify/node_modules/bunyan/tmp/log4js-node/.npmignore
  76. +0 −249 node_modules/restify/node_modules/bunyan/tmp/log4js-node/README.md
  77. +0 −14 node_modules/restify/node_modules/bunyan/tmp/log4js-node/example-connect-logger.js
  78. +0 −22 node_modules/restify/node_modules/bunyan/tmp/log4js-node/example.js
  79. +0 −21 node_modules/restify/node_modules/bunyan/tmp/log4js-node/lib/appenders/console.js
  80. +0 −63 node_modules/restify/node_modules/bunyan/tmp/log4js-node/lib/appenders/file.js
  81. +0 −98 node_modules/restify/node_modules/bunyan/tmp/log4js-node/lib/appenders/gelf.js
  82. +0 −76 node_modules/restify/node_modules/bunyan/tmp/log4js-node/lib/appenders/hookio.js
  83. +0 −21 node_modules/restify/node_modules/bunyan/tmp/log4js-node/lib/appenders/logLevelFilter.js
  84. +0 −77 node_modules/restify/node_modules/bunyan/tmp/log4js-node/lib/appenders/multiprocess.js
  85. +0 −76 node_modules/restify/node_modules/bunyan/tmp/log4js-node/lib/appenders/smtp.js
  86. +0 −168 node_modules/restify/node_modules/bunyan/tmp/log4js-node/lib/connect-logger.js
  87. +0 −60 node_modules/restify/node_modules/bunyan/tmp/log4js-node/lib/date_format.js
  88. +0 −260 node_modules/restify/node_modules/bunyan/tmp/log4js-node/lib/layouts.js
  89. +0 −56 node_modules/restify/node_modules/bunyan/tmp/log4js-node/lib/levels.js
  90. +0 −409 node_modules/restify/node_modules/bunyan/tmp/log4js-node/lib/log4js.js
  91. +0 −7 node_modules/restify/node_modules/bunyan/tmp/log4js-node/lib/log4js.json
  92. +0 −268 node_modules/restify/node_modules/bunyan/tmp/log4js-node/lib/streams.js
  93. +0 −27 node_modules/restify/node_modules/bunyan/tmp/log4js-node/log-rolling.js
  94. +0 −37 node_modules/restify/node_modules/bunyan/tmp/log4js-node/memory-test.js
  95. +0 −34 node_modules/restify/node_modules/bunyan/tmp/log4js-node/package.json
  96. +0 −130 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/bufferedStream.js
  97. +0 −23 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/date_format.js
  98. +0 −149 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/fileAppender.js
  99. +0 −30 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/gelfAppender.js
  100. +0 −101 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/hookioAppender.js
  101. +0 −208 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/layouts.js
  102. +0 −16 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/log4js.json
  103. +0 −69 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/logLevelFilter.js
  104. +0 −601 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/logging.js
  105. +0 −173 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/multiprocessAppender.js
  106. +0 −126 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/rollingFileStream.js
  107. +0 −162 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/smtpAppender.js
  108. +0 −128 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/test-connect-logger.js
  109. +0 −85 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/test-global-log-level.js
  110. +0 −260 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/test-nolog.js
  111. +0 −11 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/with-log-rolling.json
  112. +0 −28 node_modules/restify/node_modules/bunyan/tmp/log4js-node/test/with-logLevelFilter.json
  113. +0 −496 node_modules/restify/node_modules/bunyan/tools/cutarelease.py
  114. +0 −86 node_modules/restify/node_modules/bunyan/tools/timechild.js
  115. +0 −29 node_modules/restify/node_modules/bunyan/tools/timeguard.js
  116. +0 −37 node_modules/restify/node_modules/bunyan/tools/timesrc.js
  117. +0 −1 node_modules/restify/node_modules/dtrace-provider/DTraceProviderBindings.node
  118. +38 −9 node_modules/restify/node_modules/dtrace-provider/package.json
  119. +4 −0 node_modules/restify/node_modules/formidable/.npmignore
  120. +0 −1 node_modules/restify/node_modules/{bunyan/tmp/log4js-node → formidable}/.travis.yml
  121. +14 −0 node_modules/restify/node_modules/formidable/Makefile
  122. +303 −0 node_modules/restify/node_modules/formidable/Readme.md
  123. +3 −0 node_modules/restify/node_modules/formidable/TODO
  124. +70 −0 node_modules/restify/node_modules/formidable/benchmark/bench-multipart-parser.js
  125. +43 −0 node_modules/restify/node_modules/formidable/example/post.js
  126. +48 −0 node_modules/restify/node_modules/formidable/example/upload.js
  127. +1 −0 node_modules/restify/node_modules/formidable/index.js
  128. +61 −0 node_modules/restify/node_modules/formidable/lib/file.js
  129. +378 −0 node_modules/restify/node_modules/formidable/lib/incoming_form.js
  130. +3 −0 node_modules/restify/node_modules/formidable/lib/index.js
  131. +312 −0 node_modules/restify/node_modules/formidable/lib/multipart_parser.js
  132. +25 −0 node_modules/restify/node_modules/formidable/lib/querystring_parser.js
  133. +6 −0 node_modules/restify/node_modules/formidable/lib/util.js
  134. +36 −0 node_modules/restify/node_modules/formidable/package.json
  135. +19 −0 node_modules/restify/node_modules/formidable/test/common.js
  136. +1 −0 node_modules/restify/node_modules/formidable/test/fixture/file/funkyfilename.txt
  137. +1 −0 node_modules/restify/node_modules/formidable/test/fixture/file/plain.txt
  138. +3 −0 node_modules/restify/node_modules/formidable/test/fixture/http/special-chars-in-filename/info.md
  139. +3 −0 node_modules/restify/node_modules/formidable/test/fixture/js/no-filename.js
  140. +21 −0 node_modules/restify/node_modules/formidable/test/fixture/js/special-chars-in-filename.js
  141. +72 −0 node_modules/restify/node_modules/formidable/test/fixture/multipart.js
  142. +89 −0 node_modules/restify/node_modules/formidable/test/integration/test-fixtures.js
  143. +24 −0 node_modules/restify/node_modules/formidable/test/legacy/common.js
  144. +80 −0 node_modules/restify/node_modules/formidable/test/legacy/integration/test-multipart-parser.js
  145. +104 −0 node_modules/restify/node_modules/formidable/test/legacy/simple/test-file.js
  146. +726 −0 node_modules/restify/node_modules/formidable/test/legacy/simple/test-incoming-form.js
  147. +50 −0 node_modules/restify/node_modules/formidable/test/legacy/simple/test-multipart-parser.js
  148. +45 −0 node_modules/restify/node_modules/formidable/test/legacy/simple/test-querystring-parser.js
  149. +72 −0 node_modules/restify/node_modules/formidable/test/legacy/system/test-multi-video-upload.js
  150. +2 −0 node_modules/restify/node_modules/formidable/test/run.js
  151. +63 −0 node_modules/restify/node_modules/formidable/test/unit/test-incoming-form.js
  152. +47 −0 node_modules/restify/node_modules/formidable/tool/record.js
  153. 0 node_modules/restify/node_modules/http-signature/node_modules/asn1/{.gitignore → .npmignore}
  154. +19 −2 node_modules/restify/node_modules/http-signature/node_modules/asn1/package.json
  155. +28 −7 node_modules/restify/node_modules/http-signature/node_modules/ctype/package.json
  156. +26 −12 node_modules/restify/node_modules/http-signature/node_modules/sprintf/package.json
  157. +18 −2 node_modules/restify/node_modules/http-signature/package.json
  158. +1 −0 node_modules/restify/node_modules/lru-cache/.npmignore
  159. +23 −0 node_modules/restify/node_modules/lru-cache/LICENSE
  160. +12 −0 node_modules/restify/node_modules/lru-cache/README.md
  161. +100 −0 node_modules/restify/node_modules/lru-cache/lib/lru-cache.js
  162. +42 −0 node_modules/restify/node_modules/lru-cache/package.json
  163. +93 −0 node_modules/restify/node_modules/lru-cache/test/basic.js
  164. +21 −8 node_modules/restify/node_modules/mime/README.md
  165. +6 −5 node_modules/restify/node_modules/mime/mime.js
  166. +31 −8 node_modules/restify/node_modules/mime/package.json
  167. +38 −64 node_modules/restify/node_modules/mime/test.js
  168. +31 −0 node_modules/restify/node_modules/mime/types/mime.types
  169. +5 −0 node_modules/restify/node_modules/mime/types/node.types
  170. +43 −11 node_modules/restify/node_modules/node-uuid/package.json
  171. +6 −0 node_modules/restify/node_modules/qs/.gitmodules
  172. +1 −0 node_modules/restify/node_modules/qs/.npmignore
  173. +2 −1 node_modules/restify/{ → node_modules/qs}/.travis.yml
  174. +73 −0 node_modules/restify/node_modules/qs/History.md
  175. +5 −0 node_modules/restify/node_modules/qs/Makefile
  176. +54 −0 node_modules/restify/node_modules/qs/Readme.md
  177. +17 −0 node_modules/restify/node_modules/qs/benchmark.js
  178. +51 −0 node_modules/restify/node_modules/qs/examples.js
  179. +2 −0 node_modules/restify/node_modules/qs/index.js
  180. +264 −0 node_modules/restify/node_modules/qs/lib/querystring.js
  181. +37 −0 node_modules/restify/node_modules/qs/package.json
  182. +2 −0 node_modules/restify/node_modules/qs/test/mocha.opts
  183. +167 −0 node_modules/restify/node_modules/qs/test/parse.js
  184. +103 −0 node_modules/restify/node_modules/qs/test/stringify.js
  185. 0 node_modules/restify/node_modules/retry/{.gitignore → .npmignore}
  186. +9 −1 node_modules/restify/node_modules/retry/Readme.md
  187. +1 −1 node_modules/restify/node_modules/retry/lib/retry.js
  188. +37 −3 node_modules/restify/node_modules/retry/lib/retry_operation.js
  189. +23 −5 node_modules/restify/node_modules/retry/package.json
  190. +11 −3 node_modules/restify/node_modules/retry/test/integration/test-retry-operation.js
  191. +41 −11 node_modules/restify/node_modules/semver/package.json
  192. +3 −1 node_modules/restify/node_modules/semver/semver.js
  193. +73 −19 node_modules/restify/package.json
  194. +58 −44 node_modules/restify/{tst → test}/client.test.js
  195. +515 −0 node_modules/restify/test/plugins.test.js
  196. +13 −13 node_modules/restify/{tst → test}/request.test.js
  197. +53 −40 node_modules/restify/{tst → test}/response.test.js
  198. +35 −35 node_modules/restify/{tst → test}/route.test.js
  199. +328 −143 node_modules/restify/{tst → test}/server.test.js
  200. +9 −9 node_modules/restify/{tst → test}/stubs.js
  201. +22 −22 node_modules/restify/{tst → test}/throttle.test.js
  202. +0 −138 node_modules/restify/tools/jsl.conf
  203. +0 −274 node_modules/restify/tst/plugins.test.js
  204. +2 −2 package.json
@@ -1,25 +1,111 @@
# bunyan Changelog
-## bunyan 0.5.2 (not yet released)
+## bunyan 0.6.8
+
+- Fix bad bug in `log.child({...}, true);` where the added child fields **would
+ be added to the parent's fields**. This bug only existed for the "fast child"
+ path (that second `true` argument). A side-effect of fixing this is that
+ the "fast child" path is only 5 times as fast as the regular `log.child`,
+ instead of 10 times faster.
+
+
+## bunyan 0.6.7
+
+- [issue #6] Fix bleeding 'type' var to global namespace. (Thanks Mike!)
+
+
+## bunyan 0.6.6
+
+- Add support to the `bunyan` CLI taking log file path args, `bunyan foo.log`,
+ in addition to the usual `cat foo.log | bunyan`.
+- Improve reliability of the default output formatting of the `bunyan` CLI.
+ Before it could blow up processing log records missing some expected
+ fields.
+
+
+## bunyan 0.6.5
+
+- ANSI coloring output from `bunyan` CLI tool (for the default output mode/style).
+ Also add the '--color' option to force coloring if the output stream is not
+ a TTY, e.g. `cat my.log | bunyan --color | less -R`. Use `--no-color` to
+ disable coloring, e.g. if your terminal doesn't support ANSI codes.
+- Add 'level' field to log record before custom fields for that record. This
+ just means that the raw record JSON will show the 'level' field earlier,
+ which is a bit nicer for raw reading.
+
+
+## bunyan 0.6.4
+
+- [issue #5] Fix `log.info() -> boolean` to work properly. Previous all were
+ returning false. Ditto all trace/debug/.../fatal methods.
+
+
+## bunyan 0.6.3
+
+- Allow an optional `msg` and arguments to the `log.info(<Error> err)` logging
+ form. For example, before:
+
+ log.debug(my_error_instance) // good
+ log.debug(my_error_instance, "boom!") // wasn't allowed
+
+ Now the latter is allowed if you want to expliciting set the log msg. Of course
+ this applies to all the `log.{trace|debug|info...}()` methods.
+
+- `bunyan` cli output: clarify extra fields with quoting if empty or have
+ spaces. E.g. 'cmd' and 'stderr' in the following:
+
+ [2012-02-12T00:30:43.736Z] INFO: mo-docs/43194 on banana.local: buildDocs results (req_id=185edca2-2886-43dc-911c-fe41c09ec0f5, route=PutDocset, error=null, stderr="", cmd="make docs")
+
+
+## bunyan 0.6.2
+
+- Fix/guard against unintended inclusion of some files in npm published package
+ due to <https://github.com/isaacs/npm/issues/2144>
+
+
+## bunyan 0.6.1
+
+- Internal: starting jsstyle usage.
+- Internal: add .npmignore. Previous packages had reams of bunyan crud in them.
+
+
+## bunyan 0.6.0
+
+- Add 'pid' automatic log record field.
+
+
+## bunyan 0.5.3
+
+- Add 'client_req' (HTTP client request) standard formatting in `bunyan` CLI
+ default output.
+- Improve `bunyan` CLI default output to include *all* log record keys. Unknown keys
+ are either included in the first line parenthetical (if short) or in the indented
+ subsequent block (if long or multiline).
+
+
+## bunyan 0.5.2
+
+- [issue #3] More type checking of `new Logger(...)` and `log.child(...)`
+ options.
+- Start a test suite.
-(nothing yet)
## bunyan 0.5.1
- [issue #2] Add guard on `JSON.stringify`ing of log records before emission.
This will prevent `log.info` et al throwing on record fields that cannot be
represented as JSON. An error will be printed on stderr and a clipped log
record emitted with a 'bunyanMsg' key including error details. E.g.:
-
+
bunyan: ERROR: could not stringify log record from /Users/trentm/tm/node-bunyan/examples/unstringifyable.js:12: TypeError: Converting circular structure to JSON
{
"name": "foo",
"hostname": "banana.local",
"bunyanMsg": "bunyan: ERROR: could not stringify log record from /Users/trentm/tm/node-bunyan/examples/unstringifyable.js:12: TypeError: Converting circular structure to JSON",
...
- Some timing shows this does effect log speed:
-
+ Some timing shows this does effect log speed:
+
$ node tools/timeguard.js # before
Time try/catch-guard on JSON.stringify:
- log.info: 0.07365ms per iteration
@@ -69,7 +155,7 @@
- `log.child(options[, simple])` Added `simple` boolean arg. Set `true` to
assert that options only add fields (no config changes). Results in a 10x
- speed increase in child creation. See "tools/timechild.js". On my Mac,
+ speed increase in child creation. See "tools/timechild.js". On my Mac,
"fast child" creation takes about 0.001ms. IOW, if your app is dishing
10,000 req/s, then creating a log child for each request will take
about 1% of the request time.
@@ -93,4 +179,3 @@
## bunyan 0.1.0
First release.
-
@@ -1,12 +1,43 @@
+#---- Tools
+
+TAP := ./node_modules/.bin/tap
+
+
+#---- Files
+
+JSSTYLE_FILES := $(shell find lib test tools -name *.js)
+
+
+
+#---- Targets
+
all:
-# Ensure jsontool.js and package.json have the same version.
+# Ensure all version-carrying files have the same version.
+.PHONY: versioncheck
versioncheck:
[[ `cat package.json | json version` == `grep '^var VERSION' bin/bunyan | awk -F'"' '{print $$2}'` ]]
[[ `cat package.json | json version` == `grep '^var VERSION' lib/bunyan.js | awk -F'"' '{print $$2}'` ]]
@echo Version check ok.
+.PHONY: cutarelease
cutarelease: versioncheck
+ [[ ! -d tmp ]] # No 'tmp/' allowed: https://github.com/isaacs/npm/issues/2144
./tools/cutarelease.py -p bunyan -f package.json -f lib/bunyan.js -f bin/bunyan
+.PHONY: test
+test: $(TAP)
+ TAP=1 $(TAP) test/*.test.js
+
+.PHONY: check-jsstyle
+check-jsstyle: $(JSSTYLE_FILES)
+ ./tools/jsstyle -o indent=2,doxygen,unparenthesized-return=0,blank-after-start-comment=0 $(JSSTYLE_FILES)
+
+.PHONY: check
+check: check-jsstyle
+ @echo "Check ok."
+
+.PHONY: prepush
+prepush: check test
+ @echo "Okay to push."
@@ -9,8 +9,8 @@ Also: log4j is way more than you need.
# Current Status
-Basic functionality there. Still a fair amount of planned work... most
-importantly the clarifying of required and suggested fields.
+Basic functionality there. Still a fair amount of planned work, but I'm using
+it for some production services.
Currently supports node 0.4+, but I'll probably make the jump to node 0.6+ as a
base soonish.
@@ -35,13 +35,17 @@ format version) are added for you.
The full `log.{trace|debug|...|fatal}(...)` API is:
log.info(); // Returns a boolean: is the "info" level enabled?
- log.info(err); // Log an `Error` instance, adds "err" key with exception details
- // (including the stack) and sets "msg" to the exception message.
- // A special case, b/c logging errors should be easy.
- log.info('hi'); // Log a simple string message.
+
+ log.info('hi'); // Log a simple string message.
log.info('hi %s', bob, anotherVar); // Uses `util.format` for msg formatting.
+
log.info({foo: 'bar'}, 'hi'); // Adds "foo" field to log record.
+ log.info(err); // Special case to log an `Error` instance, adds "err"
+ // key with exception details (including the stack) and
+ // sets "msg" to the exception message.
+ log.info(err, 'more on this: %s', more);
+ // ... or you can specify the "msg".
## bunyan tool
@@ -52,7 +56,7 @@ be added, including support for custom formats.
$ node hi.js | ./bin/bunyan # CLI tool to filter/pretty-print JSON logs.
[2012-01-31T00:08:11.387Z] INFO: myapp on banana.local: hi
-
+
$ node hi.js | ./bin/bunyan -o json
{
"name": "myapp",
@@ -69,7 +73,7 @@ be added, including support for custom formats.
By default, log output is to stdout (**stream**) and at the "info" level.
Explicitly that looks like:
- var log = new Logger({name: "myapp", stream: process.stdout,
+ var log = new Logger({name: "myapp", stream: process.stdout,
level: "info"});
That is an abbreviated form for a single stream. **You can defined multiple
@@ -101,20 +105,20 @@ same config as its parent, plus include the "component" field.
var log = new Logger(...);
...
-
+
function Wuzzle(options) {
this.log = options.log;
this.log.info("creating a wuzzle")
}
Wuzzle.prototype.woos = function () {
this.log.warn("This wuzzle is woosey.")
}
-
+
var wuzzle = new Wuzzle({log: log.child({component: "wuzzle"})});
wuzzle.woos();
log.info("done with the wuzzle")
-* * *
+### A little log.child hack.
An example and a hack: The [node-restify](https://github.com/mcavage/node-restify)
framework integrates bunyan. One feature is that each restify request handler
@@ -125,12 +129,12 @@ includes a `req.log` logger that is:
Apps using restify can then use `req.log` and have all such log records
include the unique request id (as "req_id"). Handy.
-*What is that `true`?* It is a small bunyan hack by which you can assert that
-you're just adding simple fields to the child logger. This makes `log.child`
-10x faster and, hence, never a worry for slowing down HTTP request handling.
-See the changelog for node-bunyan 0.3.0 for details.
+The hack is that `, true`. It is a small bunyan performance hack by which you
+can assert that you're just adding simple fields to the child logger -- i.e.
+not special fields like "level", "serializers", "streams". This makes
+`log.child` 10x faster and, hence, never a worry for slowing down HTTP
+request handling. See the changelog for node-bunyan 0.3.0 for details.
-* * *
## serializers
@@ -177,8 +181,8 @@ in your log record will be replaced with a short error message.*
## src
-The **call source file, line and function** (if not at the global level) can
-be added to log records by using the `src: true` config option:
+The **source file, line and function of the log call site** can be added to
+log records by using the `src: true` config option:
var log = new Logger({src: true, ...});
@@ -205,34 +209,36 @@ in production.**
# Levels
+The log levels in bunyan are:
+
- "fatal" (60): the service/app is going to stop or become unusable now
- "error" (50): fatal for a particular request, but the service/app continues servicing other requests
- "warn" (40): a note on something that should probably be looked at by an operator
- "info" (30): detail on regular operation
- "debug" (20): anything else, i.e. too verbose to be included in "info" level.
- "trace" (10): logging from external libraries used by your app
-"debug" should be used sparingly. Information that will be useful to debug
-errors *post mortem* should usually be included in "info" messages if it's
-generally relevant or else with the corresponding "error" event. Don't rely on
-spewing mostly irrelevant debug messages all the time and sifting through them
-when an error occurs.
+General level usage suggestions: "debug" should be used sparingly.
+Information that will be useful to debug errors *post mortem* should usually
+be included in "info" messages if it's generally relevant or else with the
+corresponding "error" event. Don't rely on spewing mostly irrelevant debug
+messages all the time and sifting through them when an error occurs.
-Integers are used for the actual level values (1 for "trace", ..., 6 for
+Integers are used for the actual level values (10 for "trace", ..., 60 for
"fatal") and constants are defined for the (Logger.TRACE ... Logger.DEBUG).
The lowercase level names are aliases supported in the API.
Here is the API for changing levels in an existing logger:
log.level() -> INFO // gets current level (lowest level of all streams)
-
+
log.level(INFO) // set all streams to level INFO
log.level("info") // set all streams to level INFO
log.levels() -> [DEBUG, INFO] // get array of levels of all streams
log.levels(0) -> DEBUG // get level of stream at index 0
log.levels("foo") // get level of stream with name "foo"
-
+
log.levels(0, INFO) // set level of stream 0 to INFO
log.levels(0, "info") // can use "info" et al aliases
log.levels("foo", WARN) // set stream named "foo" to WARN
@@ -256,13 +262,14 @@ incorrect signature) is always a bug in Bunyan.**
A typical Bunyan log record looks like this:
- {"name":"myserver","hostname":"banana.local","req":{"method":"GET","url":"/path?q=1#anchor","headers":{"x-hi":"Mom","connection":"close"}},"level":3,"msg":"start request","time":"2012-02-03T19:02:46.178Z","v":0}
+ {"name":"myserver","hostname":"banana.local","pid":123,"req":{"method":"GET","url":"/path?q=1#anchor","headers":{"x-hi":"Mom","connection":"close"}},"level":3,"msg":"start request","time":"2012-02-03T19:02:46.178Z","v":0}
Pretty-printed:
{
"name": "myserver",
"hostname": "banana.local",
+ "pid": 123,
"req": {
"method": "GET",
"url": "/path?q=1#anchor",
@@ -296,6 +303,7 @@ Core fields:
- `hostname`: Required. String. Provided or determined at Logger creation.
You can specify your hostname at Logger creation or it will be retrieved
vi `os.hostname()`.
+- `pid`: Required. Integer. Filled in automatically at Logger creation.
- `time`: Required. String. Added by Bunion. Can be overriden.
The date and time of the event in [ISO 8601
Extended Format](http://en.wikipedia.org/wiki/ISO_8601) format and in UTC,
@@ -317,7 +325,7 @@ Recommended/Best Practice Fields:
- `err`: Object. A caught JS exception. Log that thing with `log.info(err)`
to get:
-
+
...
"err": {
"message": "boom",
@@ -340,7 +348,7 @@ Recommended/Best Practice Fields:
- `req`: An HTTP server request. Bunyan provides `Logger.stdSerializers.req`
to serialize a request with a suggested set of keys. Example:
-
+
{
"method": "GET",
"url": "/path?q=1#anchor",
@@ -353,7 +361,7 @@ Recommended/Best Practice Fields:
}
- `res`: An HTTP server response. Bunyan provides `Logger.stdSerializers.res`
- to serialize a response with a suggested set of keys. Example:
+ to serialize a response with a suggested set of keys. Example:
{
"statusCode": 200,
@@ -446,5 +454,3 @@ See "TODO.md", but basically:
- Syslog support.
- Some speed comparisons with others to get a feel for Bunyan's speed.
-
-
Oops, something went wrong.

0 comments on commit e75502a

Please sign in to comment.