Skip to content

Commit

Permalink
logger package
Browse files Browse the repository at this point in the history
  • Loading branch information
vr-varad committed Feb 14, 2025
1 parent 4ea6178 commit e14a9ad
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 2 deletions.
19 changes: 19 additions & 0 deletions packages/Logger/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Logger {
log(message) {
console.log("[LOG] " + [new Date().toISOString(), message].join(' - '));
}

error(message) {
console.error("[ERROR] " + [new Date().toISOString(), message].join(' - '));
}

warn(message) {
console.warn("[WARNING] " + [new Date().toISOString(), message].join(' - '));
}

success(message) {
console.log("[SUCCESS] " + [new Date().toISOString(), message].join(' - '));
}
}

export default new Logger();
13 changes: 13 additions & 0 deletions packages/Logger/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "@code_blaster/logger",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
12 changes: 12 additions & 0 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"start": "node index.js",
"test:integration": "./scripts/run-integration.sh"
},
"workspaces":[
"../packages/*"
],
"keywords": [],
"author": "",
"license": "ISC",
Expand Down
3 changes: 2 additions & 1 deletion server/providers/Database.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Logger from "@code_blaster/logger"
import mongoose from "mongoose"

class Database {
Expand All @@ -6,7 +7,7 @@ class Database {
mongoose.connect(MONGO_URI, {
dbName: "code_blaster_3000"
}).then(() => {
console.log("Database Connected")
Logger.log("Database Connected")
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion server/providers/Express.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import express from "express"
import { Routes } from "../route/index.js"
import { errorHandler } from "../utils/errorHandler.js"
import Logger from "@code_blaster/logger";

class Express {
static app = express();
Expand All @@ -14,7 +15,7 @@ class Express {

static startServer() {
this.app.listen(this.PORT, () => {
console.log("The Server is Running on Port: ", this.PORT)
Logger.log("Server Starting At Port " + this.PORT)
})
}
}
Expand Down

0 comments on commit e14a9ad

Please sign in to comment.