Skip to content

Commit 1783b27

Browse files
committed
v1.0.0
- Published successfully to npmjs.com
1 parent 646615d commit 1783b27

File tree

5 files changed

+35
-19
lines changed

5 files changed

+35
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Star on GitHub](https://img.shields.io/github/stars/samestrin/advanced-console-log?style=social)](https://github.com/samestrin/advanced-console-log/stargazers) [![Fork on GitHub](https://img.shields.io/github/forks/samestrin/advanced-console-log?style=social)](https://github.com/samestrin/advanced-console-log/network/members) [![Watch on GitHub](https://img.shields.io/github/watchers/samestrin/advanced-console-log?style=social)](https://github.com/samestrin/advanced-console-log/watchers)
44

5-
![Version 0.0.6](https://img.shields.io/badge/Version-0.0.6-blue) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Built with Node.js](https://img.shields.io/badge/Built%20with-Node.js-green)](https://nodejs.org/)
5+
![Version 1.0.0](https://img.shields.io/badge/Version-1.0.0-blue) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Built with Node.js](https://img.shields.io/badge/Built%20with-Node.js-green)](https://nodejs.org/)
66

77
**Advanced Console Log (ACL)**, available as the `advanced-console-log` NPM package, is a lightweight logging module for Node.js applications. It supports console and file logging with various levels, colors, and additional features such as memory usage tracking and caller information.
88

examples/configuration-options.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
const ACL = require("../index");
7-
87
// Create an instance of ACL with custom configuration
98
const logger = ACL.getInstance({
109
logLevel: 1, // Set console log level

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "advanced-console-log",
3-
"version": "0.0.6",
3+
"version": "1.0.0",
44
"description": "Advanced Console Log (ACL), available as the `advanced-console-log` NPM package, is a lightweight logging module for Node.js applications. It supports console and file logging with various levels, colors, and additional features such as memory usage tracking and caller information.",
55
"main": "index.js",
66
"directories": {
77
"doc": "docs",
8-
"lib": "lib"
8+
"example": "examples"
99
},
1010
"scripts": {
1111
"test": "echo \"Error: no test specified\" && exit 1"

src/core/ACL.js

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,33 @@ class ACL {
144144
registry.register(this, { cleanup: () => this.close() });
145145
}
146146

147+
/**
148+
* Dynamically loads methods and properties from the provided utility class into this instance.
149+
* @param {class} SupportClass - Class containing methods and properties to be loaded.
150+
*/
151+
loadMethodsAndProperties(SupportClass) {
152+
const supportClass = new SupportClass();
153+
154+
// Get all properties and methods from the utility class, including inherited ones
155+
Object.getOwnPropertyNames(SupportClass.prototype).forEach(
156+
(propertyName) => {
157+
if (propertyName !== "constructor") {
158+
// Check if it's a method and bind it
159+
if (typeof supportClass[propertyName] === "function") {
160+
this[propertyName] = supportClass[propertyName].bind(this);
161+
}
162+
}
163+
}
164+
);
165+
166+
// Get all instance variables from the utility class
167+
Object.keys(supportClass).forEach((variableName) => {
168+
if (typeof supportClass[variableName] !== "function") {
169+
this[variableName] = supportClass[variableName];
170+
}
171+
});
172+
}
173+
147174
_initializeReportGenerator() {
148175
if (!ReportGenerator) {
149176
ReportGenerator = require("./ReportGenerator");
@@ -482,11 +509,11 @@ class ACL {
482509
// Format based on the specified level
483510
switch (level) {
484511
case 1:
485-
return ` ${relativeFilePath}:`;
512+
return `${relativeFilePath}:`;
486513
case 2:
487-
return ` ${relativeFilePath} (${lineNumber}, ${columnNumber}):`;
514+
return `${relativeFilePath} (${lineNumber}, ${columnNumber}):`;
488515
case 3:
489-
return ` ${relativeFilePath} (${lineNumber}, ${columnNumber}) > ${callerFunction}:`;
516+
return `${relativeFilePath} (${lineNumber}, ${columnNumber}) > ${callerFunction}:`;
490517
default:
491518
return "";
492519
}
@@ -545,21 +572,11 @@ class ACL {
545572
* @returns {string} The formatted caller information to be included in the log.
546573
*/
547574
getFormattedCallerInfo(level) {
548-
let callerInfo = "";
549-
550-
// Inline caller info
551-
if (this.includeInlineCallerInfo && level >= this.inlineCallerInfoLevel) {
552-
callerInfo += `${this.color.inlineCaller}${this.getInlineCallerInfo(
553-
this.inlineCallerInfoLevel
554-
)}${COLORS.RESET} `;
555-
}
556-
557-
// Regular caller info
558575
if (this.includeCallerInfo && level >= this.callerInfoLevel) {
559-
callerInfo += this.getCallerInfo();
576+
return this.getCallerInfo();
560577
}
561578

562-
return callerInfo;
579+
return "";
563580
}
564581

565582
getLogLevelName(level) {

src/handlers/ConsoleHandler.js

Whitespace-only changes.

0 commit comments

Comments
 (0)