1.0.0 • Published 2 years ago
db_level_logger v1.0.0
Database level log in to system
Installing
Using npm:
$ npm install db_level_logger
Using bower:
$ bower install db_level_logger
Using yarn:
$ yarn add db_level_logger
Important Note
You have to make sure that , you have to use this package before calling and APIs on server.
Way of Use
note: CommonJS usage
In order to gain the CommonJS imports with require()
use the following approach:
const express = require("express");
const server =express();
const port =3000 // Entered you port
const dbLogs = require("db_level_logger");
// Database connection function and process
// After this connection process pass connection object into dbLogs
// Database connection sample code
// Database connection
const oracleDB = require("oracledb");
let conn;
const dbConnection = async () => {
try {
oracleDB.initOracleClient({
libDir: "libDir"
});
conn = await oracleDB.createPool({
user: 'USERNAME',
password: 'PASSWORD',
connectString: 'HOST:PORT/DATABASE',
})
const result = await conn.getConnection();
console.log("Successfully connected to Oracle!");
return result;
} catch (error) {
console.log(error)
}
}
const connection = dbConnection().then(conn => { return conn; });
// You need to pass table name and connection object for store data into table
server.use(dbLogs("Table",connection))
server.listen(port, () => console.log(`listening on port ${port}!`));
1.0.0
2 years ago