Ein Projekt das es ermöglicht Beerpong über das Internet von zwei unabhängigen positionen aus zu spielen. Entstehung im Rahmen einer Praktikumsaufgabe im Fach Interaktion.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. # morgan
  2. [![NPM Version][npm-image]][npm-url]
  3. [![NPM Downloads][downloads-image]][downloads-url]
  4. [![Build Status][travis-image]][travis-url]
  5. [![Test Coverage][coveralls-image]][coveralls-url]
  6. [![Gratipay][gratipay-image]][gratipay-url]
  7. HTTP request logger middleware for node.js
  8. > Named after [Dexter](http://en.wikipedia.org/wiki/Dexter_Morgan), a show you should not watch until completion.
  9. ## API
  10. ```js
  11. var morgan = require('morgan')
  12. ```
  13. ### morgan(format, options)
  14. Create a new morgan logger middleware function using the given `format` and `options`.
  15. The `format` argument may be a string of a predefined name (see below for the names),
  16. a string of a format string, or a function that will produce a log entry.
  17. #### Options
  18. Morgan accepts these properties in the options object.
  19. #### buffer
  20. Buffer duration before writing logs to the `stream`, defaults to `false`. When
  21. set to `true`, defaults to `1000 ms`.
  22. #### immediate
  23. Write log line on request instead of response. This means that a requests will
  24. be logged even if the server crashes, _but data from the response (like the
  25. response code, content length, etc.) cannot be logged_.
  26. ##### skip
  27. Function to determine if logging is skipped, defaults to `false`. This function
  28. will be called as `skip(req, res)`.
  29. ```js
  30. // EXAMPLE: only log error responses
  31. morgan('combined', {
  32. skip: function (req, res) { return res.statusCode < 400 }
  33. })
  34. ```
  35. ##### stream
  36. Output stream for writing log lines, defaults to `process.stdout`.
  37. #### Predefined Formats
  38. There are various pre-defined formats provided:
  39. ##### combined
  40. Standard Apache combined log output.
  41. ```
  42. :remote-addr - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"
  43. ```
  44. ##### common
  45. Standard Apache common log output.
  46. ```
  47. :remote-addr - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length]
  48. ```
  49. ##### dev
  50. Concise output colored by response status for development use. The `:status`
  51. token will be colored red for server error codes, yellow for client error
  52. codes, cyan for redirection codes, and uncolored for all other codes.
  53. ```
  54. :method :url :status :response-time ms - :res[content-length]
  55. ```
  56. ##### short
  57. Shorter than default, also including response time.
  58. ```
  59. :remote-addr :remote-user :method :url HTTP/:http-version :status :res[content-length] - :response-time ms
  60. ```
  61. ##### tiny
  62. The minimal output.
  63. ```
  64. :method :url :status :res[content-length] - :response-time ms
  65. ```
  66. #### Tokens
  67. - `:req[header]` ex: `:req[Accept]`
  68. - `:res[header]` ex: `:res[Content-Length]`
  69. - `:http-version`
  70. - `:response-time`
  71. - `:remote-addr`
  72. - `:remote-user`
  73. - `:date`
  74. - `:method`
  75. - `:url`
  76. - `:referrer`
  77. - `:user-agent`
  78. - `:status`
  79. To define a token, simply invoke `morgan.token()` with the name and a callback function. The value returned is then available as ":type" in this case:
  80. ```js
  81. morgan.token('type', function(req, res){ return req.headers['content-type']; })
  82. ```
  83. ## Examples
  84. ### express/connect
  85. Simple app that will log all request in the Apache combined format to STDOUT
  86. ```js
  87. var express = require('express')
  88. var morgan = require('morgan')
  89. var app = express()
  90. app.use(morgan('combined'))
  91. app.get('/', function (req, res) {
  92. res.send('hello, world!')
  93. })
  94. ```
  95. ### vanilla http server
  96. Simple app that will log all request in the Apache combined format to STDOUT
  97. ```js
  98. var finalhandler = require('finalhandler')
  99. var http = require('http')
  100. var morgan = require('morgan')
  101. // create "middleware"
  102. var logger = morgan('combined')
  103. http.createServer(function (req, res) {
  104. var done = finalhandler(req, res)
  105. logger(req, res, function (err) {
  106. if (err) return done(err)
  107. // respond to request
  108. res.setHeader('content-type', 'text/plain')
  109. res.end('hello, world!')
  110. })
  111. })
  112. ```
  113. ### write logs to a file
  114. Simple app that will log all request in the Apache combined format to the file "access.log"
  115. ```js
  116. var express = require('express')
  117. var fs = require('fs')
  118. var morgan = require('morgan')
  119. var app = express()
  120. // create a write stream (in append mode)
  121. var accessLogStream = fs.createWriteStream(__dirname + '/access.log', {flags: 'a'})
  122. // setup the logger
  123. app.use(morgan('combined', {stream: accessLogStream}))
  124. app.get('/', function (req, res) {
  125. res.send('hello, world!')
  126. })
  127. ```
  128. ## License
  129. [MIT](LICENSE)
  130. [npm-image]: https://img.shields.io/npm/v/morgan.svg?style=flat
  131. [npm-url]: https://npmjs.org/package/morgan
  132. [travis-image]: https://img.shields.io/travis/expressjs/morgan.svg?style=flat
  133. [travis-url]: https://travis-ci.org/expressjs/morgan
  134. [coveralls-image]: https://img.shields.io/coveralls/expressjs/morgan.svg?style=flat
  135. [coveralls-url]: https://coveralls.io/r/expressjs/morgan?branch=master
  136. [downloads-image]: http://img.shields.io/npm/dm/morgan.svg?style=flat
  137. [downloads-url]: https://npmjs.org/package/morgan
  138. [gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg?style=flat
  139. [gratipay-url]: https://www.gratipay.com/dougwilson/