~ubuntu-branches/ubuntu/vivid/node-log4js/vivid

« back to all changes in this revision

Viewing changes to examples/flush-on-exit.js

  • Committer: Package Import Robot
  • Author(s): Mike Gabriel
  • Date: 2014-08-20 14:19:20 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20140820141920-8cl8s6ak7uzl8jfe
Tags: 0.6.18-1
* New upstream release.
* debian/rules:
  + Add get-orig-source rule.
* debian/control:
  + Bump Standards: to 3.9.5. No changes needed.
  + Move packaging Git to pkg-javascript namespace on Alioth.
* debian/patches:
  + Refresh and update 001_debian-log4js-examples.patch. Make sure
    upstream's new example files find the log4js module when installed
    on Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * run this, then "ab -c 10 -n 100 localhost:4444/" to test (in
 
3
 * another shell)
 
4
 */
 
5
var log4js = require('./lib/log4js');
 
6
log4js.configure({
 
7
      appenders: [
 
8
        { type: 'file', filename: 'cheese.log', category: 'cheese' },
 
9
        { type: 'console'}
 
10
  ]
 
11
});
 
12
 
 
13
var logger = log4js.getLogger('cheese');
 
14
logger.setLevel('INFO');
 
15
 
 
16
var http=require('http');
 
17
 
 
18
var server = http.createServer(function(request, response){
 
19
    response.writeHead(200, {'Content-Type': 'text/plain'});
 
20
    var rd = Math.random() * 50;
 
21
    logger.info("hello " + rd);
 
22
    response.write('hello ');
 
23
    if (Math.floor(rd) == 30){
 
24
        log4js.shutdown(function() { process.exit(1); });
 
25
    }
 
26
    response.end();
 
27
}).listen(4444);