Skip to content

Commit e14a9ad

Browse files
committed
logger package
1 parent 4ea6178 commit e14a9ad

File tree

6 files changed

+51
-2
lines changed

6 files changed

+51
-2
lines changed

packages/Logger/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Logger {
2+
log(message) {
3+
console.log("[LOG] " + [new Date().toISOString(), message].join(' - '));
4+
}
5+
6+
error(message) {
7+
console.error("[ERROR] " + [new Date().toISOString(), message].join(' - '));
8+
}
9+
10+
warn(message) {
11+
console.warn("[WARNING] " + [new Date().toISOString(), message].join(' - '));
12+
}
13+
14+
success(message) {
15+
console.log("[SUCCESS] " + [new Date().toISOString(), message].join(' - '));
16+
}
17+
}
18+
19+
export default new Logger();

packages/Logger/package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "@code_blaster/logger",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"type": "module",
7+
"scripts": {
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"keywords": [],
11+
"author": "",
12+
"license": "ISC"
13+
}

server/package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"start": "node index.js",
99
"test:integration": "./scripts/run-integration.sh"
1010
},
11+
"workspaces":[
12+
"../packages/*"
13+
],
1114
"keywords": [],
1215
"author": "",
1316
"license": "ISC",

server/providers/Database.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Logger from "@code_blaster/logger"
12
import mongoose from "mongoose"
23

34
class Database {
@@ -6,7 +7,7 @@ class Database {
67
mongoose.connect(MONGO_URI, {
78
dbName: "code_blaster_3000"
89
}).then(() => {
9-
console.log("Database Connected")
10+
Logger.log("Database Connected")
1011
})
1112
}
1213
}

server/providers/Express.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import express from "express"
22
import { Routes } from "../route/index.js"
33
import { errorHandler } from "../utils/errorHandler.js"
4+
import Logger from "@code_blaster/logger";
45

56
class Express {
67
static app = express();
@@ -14,7 +15,7 @@ class Express {
1415

1516
static startServer() {
1617
this.app.listen(this.PORT, () => {
17-
console.log("The Server is Running on Port: ", this.PORT)
18+
Logger.log("Server Starting At Port " + this.PORT)
1819
})
1920
}
2021
}

0 commit comments

Comments
 (0)