GithubHelp home page GithubHelp logo

Comments (8)

houbenbert avatar houbenbert commented on August 20, 2024 4

If you do not want to see all HTTP requests, you will need to disable the logging middleware as described in README.md.

So in stead of a bs-config.json , use a bs-config.js file like this one:

module.exports = {
  logLevel: "silent",
  server: {
    middleware: {
      0: null
    }
  }
};

the 0:null clears out the first middleware, which is the logger.
You might still want to set the logLevel to "silent" or "debug" as well, since browsersync by itself can be quite verbose as well

from lite-server.

GabrielDelepine avatar GabrielDelepine commented on August 20, 2024 1

Personally I wanted to keep the middleware logger, but hide the success response. So I finally use npm start |grep -v "200" |grep -v "304"

from lite-server.

raphaelparent avatar raphaelparent commented on August 20, 2024

👍 would love to have a way to hide those logs.

from lite-server.

terciodemelo avatar terciodemelo commented on August 20, 2024

I'd recommend to write your "lite" script like that:
"lite": "lite-server -c bs-config.json > /dev/null",
It works fine to me

from lite-server.

lasanthabandara avatar lasanthabandara commented on August 20, 2024

Thanks @houbenbert ! works like a charm!

from lite-server.

rbosneag avatar rbosneag commented on August 20, 2024

Thanks @GabrielDelepine, exactly what I needed!

from lite-server.

fromcouch avatar fromcouch commented on August 20, 2024

Any change to remove 200 and 304 code natively?

I have the same behaviour and I wish to made via bs-config.

Thanks

from lite-server.

hamioraz avatar hamioraz commented on August 20, 2024

A quick hack: lite-server configures the http request logger in lib\config-defaults.js which in turn uses the module 'connect-logger'

var log = require('connect-logger')

Intercept log messages by putting a wrapper around the log function:

var proxy = function(options) {

    console.log('Proxy logger');
    var targetLog = log(options);

    return function(req, res, next) {
        var originalEnd = res.end;
        var targetNext = targetLog(req, res, next);

        //res.end is now a new function
        var targetEnd = res.end;

        res.end = function(chunk, encoding) {
            if (res.statusCode === 200 || res.statusCode === 304) {
                res.end = originalEnd;
                res.end(chunk, encoding);
                return undefined;
            } else {
                return targetEnd(chunk, encoding);
            }
        };
        return targetNext;
    };
}

And in the middleware config replace log() with proxy():

proxy({ format: '%date %status %method %url' })

A bit painful because of the nesting hell. Probably a simpler solution but works for me

from lite-server.

Related Issues (20)

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.