All Projects → nemanjapetrovic → mongoose-morgan

nemanjapetrovic / mongoose-morgan

Licence: MIT license
An npm package for saving morgan log inside MongoDB

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to mongoose-morgan

uuid-mongodb
📇 Generates and parses MongoDB BSON UUIDs
Stars: ✭ 94 (+571.43%)
Mutual labels:  mongo, mongoose
NodeScalableArchitecture
A Scalable Node Architecture/Server. This repository contains a complete implementation of writing scalable nodejs server/architecture on my medium blog.
Stars: ✭ 62 (+342.86%)
Mutual labels:  mongo, mongoose
ELog
ELog----日志打印工具,带定位功能
Stars: ✭ 17 (+21.43%)
Mutual labels:  log, error
TrackJS-Node
TrackJS Error Monitoring agent for NodeJS
Stars: ✭ 26 (+85.71%)
Mutual labels:  error-monitoring, error
Multiplatform-Log
Kotlin Multi Platform Logger, for android an ios : Logcat & print
Stars: ✭ 49 (+250%)
Mutual labels:  log, logger
GoogleCloudLogging
Swift (Darwin) library for logging application events in Google Cloud.
Stars: ✭ 24 (+71.43%)
Mutual labels:  log, logger
Natours
An awesome tour booking web app written in NodeJS, Express, MongoDB 🗽
Stars: ✭ 94 (+571.43%)
Mutual labels:  mongoose, morgan
log
A simple to use log system, minimalist but with features for debugging and differentiation of messages
Stars: ✭ 21 (+50%)
Mutual labels:  log, logger
react-native-log-ios
React Native iOS standalone logger
Stars: ✭ 37 (+164.29%)
Mutual labels:  log, logger
webpack-log
A logger for the Webpack ecosystem
Stars: ✭ 18 (+28.57%)
Mutual labels:  log, logger
apollo-log
A logging extension for the Apollo GraphQL Server
Stars: ✭ 64 (+357.14%)
Mutual labels:  log, logger
PoShLog
🔩 PoShLog is PowerShell cross-platform logging module. It allows you to log structured event data into console, file and much more places easily. It's built upon great C# logging library Serilog - https://serilog.net/
Stars: ✭ 108 (+671.43%)
Mutual labels:  log, logger
l
Cross-platform html/io [L]ogger with simple API.
Stars: ✭ 26 (+85.71%)
Mutual labels:  log, logger
mern-stack-crud
MERN stack (MongoDB, Express, React and Node.js) create read update and delete (CRUD) web application example
Stars: ✭ 142 (+914.29%)
Mutual labels:  mongo, mongoose
express-mongo-jwt-boilerplate
Express Mongo JsonWebToken boilerplate
Stars: ✭ 100 (+614.29%)
Mutual labels:  mongo, mongoose
guzzle-log-middleware
A Guzzle middleware to log request and responses automatically
Stars: ✭ 61 (+335.71%)
Mutual labels:  log, logger
clue
a extremely high performance log library for android. 高性能的Android日志库
Stars: ✭ 27 (+92.86%)
Mutual labels:  log, logger
koa-session-mongoose
Mongoose store for Koa sessions
Stars: ✭ 29 (+107.14%)
Mutual labels:  mongo, mongoose
log
PSR-3 compatible logger
Stars: ✭ 32 (+128.57%)
Mutual labels:  log, logger
missionlog
🚀 lightweight logging • supports level based filtering and tagging • weighs in at around 500 bytes
Stars: ✭ 19 (+35.71%)
Mutual labels:  log, logger

mongoose-morgan

dependencies Status devDependencies Status Known Vulnerabilities

NPM

Is npm package which combines mongoose and morgan packages by adding additional functionality to log morgan data into a MongoDB database.

Install

To install this package just run:

npm install mongoose-morgan

Basic usage example

Here is an example of using mongoose-morgan together with the express app:

// express
var express = require('express');
var app = express();

// mongoose-morgan
var morgan = require('mongoose-morgan');

// connection-data
var port = process.env.port || 8080;

// Logger
app.use(morgan({
    connectionString: 'mongodb://localhost:27017/logs-db'
}));

// run
app.listen(port);
console.log('works... ' + port);

The example from the above will create inside logs-db database collection called logs and will store data inside it.

Detailed usage

mongoose-morgan accepts three parameters:

  • mongoData : object type with next properties
    • required {string} connectionString
    • optional {string} collection
    • optional {string} user
    • optional {string} pass
    • optional {bool} capped (pull req by @Ni55aN)
    • optional {int} cappedSize (pull req by @Ni55aN)
    • optional {int} cappedMax (pull req by @Ni55aN)
    • optional {string} dbName (pull req by @pmstss)
    • optional {bool} useNewUrlParser (default: true)
    • optional {bool} useUnifiedTopology (default: true) (issue #8)
  • options : object type - standard morgan options
  • format : string type - standard morgan format

Example without morgan options:

app.use(morgan({
    connectionString: 'mongodb://localhost:27017/logs-db'
   }, {}, 'short'
));

Full example:

app.use(morgan({
    collection: 'error_logger',
    connectionString: 'mongodb://localhost:27017/logs-db',
    user: 'admin',
    pass: 'test12345'
   },
   {
    skip: function (req, res) {
        return res.statusCode < 400;
    }
   },
   'dev'
));

The code above will log data in dev format and will skip logging if the response status code is less than 400. Data will be stored in logs-db database in error_logger collection.

Contribution

Feel free to contribute by forking this repository, making changes, and submitting pull requests. For any questions or advice create an issue in this repository.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].