Code Monkey home page Code Monkey logo

connect-logger's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

connect-logger's Issues

replace error

I've a js file as following:
var connect = require('connect');
var http = require('http');
var fs=require('fs');

var app = connect();

// gzip/deflate outgoing responses
var compression = require('compression');
app.use(compression());

// store session state in browser cookie
var cookieSession = require('cookie-session');
app.use(cookieSession({
keys: ['secret1', 'secret2']
}))

// parse urlencoded request bodies into req.body
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded());

var logger= require('connect-logger');
app.use(logger('short'));

app.use(function(req,res,next){
console.error('%s %s', req.method, req.url);
next();
});

app.use(function(req, res,next){
if('GET'==req.method && '/'==req.url){
server(res,__dirname+'/index.html', 'text/html');
}
else{
next();
}
});

app.use(function(req, res ,next){

if('GET'==req.method && '/images'==req.url.substr(0,7) && '.jpg'==req.url.substr(-4)){
    server(res,__dirname+req.url, 'application/jpg');
}else{
    next();
}

});

app.use(function(req, res ,next){

res.writeHead(404);
res.end('Not found');

});

//create node.js http server and listen on port
http.createServer(app).listen(3000);

function server(res,path, type){
res.writeHead(200,{'Coent-Type':type});
fs.createReadStream(path).pipe(res);

}

when run node, the error found:
E:\eclipse42_wk\nodeconn\src\node_modules\connect-logger\lib\logger.js:13
format = format.replace(/%date/g, "\x1b[90m" + (moment().format(options.da
^
TypeError: Cannot call method 'replace' of undefined
at parse (E:\eclipse42_wk\nodeconn\src\node_modules\connect-logger\lib\logge
r.js:13:21)
at ServerResponse.res.end (E:\eclipse42_wk\nodeconn\src\node_modules\connect
-logger\lib\logger.js:41:17)
at ReadStream.onend (_stream_readable.js:485:10)
at ReadStream.g (events.js:180:16)
at ReadStream.emit (events.js:117:20)
at _stream_readable.js:929:16
at process._tickCallback (node.js:419:13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.