New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

awesome-logging

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

awesome-logging - npm Package Compare versions

Comparing version 0.0.8 to 0.1.0

1

lib/awesome-logger.d.ts

@@ -9,3 +9,2 @@ import { TextObject, TextValue } from './models/text-object';

private static _lastRenderedLines;
private static _lastScrollAmount;
private static _maxLinesInTerminal;

@@ -12,0 +11,0 @@ static restrictedLogging: boolean;

42

lib/awesome-logger.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AwesomeLogger = void 0;
var terminalSizeModule = require('window-size');
var text_object_1 = require("./models/text-object");

@@ -65,3 +64,6 @@ var multi_logger_1 = require("./logger/models/multi-logger");

AwesomeLogger.renderScrollWindow = function (allLines, scrollAmount, needsScroll) {
var _a, _b, _c, _d;
var _a, _b;
if (this.maxLinesInTerminal > allLines.length) {
needsScroll = false;
}
if (!needsScroll) {

@@ -73,25 +75,33 @@ for (var i = 0; i < allLines.length; i++) {

}
this._lastScrollAmount = scrollAmount;
return;
}
if (AwesomeLogger.restrictedLogging) {
scrollAmount = 0;
var maxScrollAmount = allLines.length - this.maxLinesInTerminal + 1;
if (scrollAmount > maxScrollAmount && maxScrollAmount > 0) {
scrollAmount = maxScrollAmount;
}
var acutalLines = new Array(this.maxLinesInTerminal);
var preDots = scrollAmount > 0;
var postDots = scrollAmount <= allLines.length - this.maxLinesInTerminal;
var visibleLineCount = this.visibleLineCount(allLines) - (preDots ? 1 : 0) - (postDots ? 1 : 0);
var lineRenderCount = this.maxLinesInTerminal - (preDots ? 1 : 0) - (postDots ? 1 : 0);
if (preDots) {
process.stdout.write(new text_object_1.TextObject('...', 'GRAY').toLineString((_b = this._lastRenderedLines) === null || _b === void 0 ? void 0 : _b[0]));
ansi_utils_1.INSERT_LINE();
acutalLines[0] = new text_object_1.TextObject('...', 'GRAY');
}
for (var i = 0; i < visibleLineCount; i++) {
if (postDots) {
acutalLines[acutalLines.length - 1] = new text_object_1.TextObject('...', 'GRAY');
}
for (var i = 0; i < lineRenderCount; i++) {
var line = allLines[i + scrollAmount];
process.stdout.write(line.toLineString((_c = this._lastRenderedLines) === null || _c === void 0 ? void 0 : _c[i + this._lastScrollAmount]));
ansi_utils_1.INSERT_LINE();
acutalLines[i + (preDots ? 1 : 0)] = line;
}
if (postDots) {
process.stdout.write(new text_object_1.TextObject('...', 'GRAY').toLineString((_d = this._lastRenderedLines) === null || _d === void 0 ? void 0 : _d[this._lastRenderedLines.length - 1]));
ansi_utils_1.MOVE_LEFT();
for (var i = 0; i < acutalLines.length; i++) {
var line = acutalLines[i];
process.stdout.write(line.toLineString((_b = this._lastRenderedLines) === null || _b === void 0 ? void 0 : _b[i]));
if (i < acutalLines.length - 1) {
ansi_utils_1.INSERT_LINE();
}
else {
ansi_utils_1.MOVE_LEFT();
}
}
this._lastScrollAmount = scrollAmount;
this._lastRenderedLines = acutalLines;
};

@@ -182,3 +192,2 @@ AwesomeLogger.log = function (type, config) {

this.renderScrollWindow(renderedLines, this.activeLogger.scrollAmount, this.activeLogger.needsScroll());
this._lastRenderedLines = renderedLines;
};

@@ -211,3 +220,2 @@ AwesomeLogger.prompt = function (type, config) {

};
AwesomeLogger._lastScrollAmount = 0;
AwesomeLogger._maxLinesInTerminal = 25;

@@ -214,0 +222,0 @@ AwesomeLogger.restrictedLogging = false;

@@ -6,3 +6,2 @@ import { AwesomeLoggerBase } from '../../logger/models/logger-base';

protected _hasChanges: boolean;
private _readStream;
private _promptFinished;

@@ -9,0 +8,0 @@ private _promptCancelled;

@@ -51,21 +51,10 @@ "use strict";

AwesomePromptBase.prototype.inputFinished = function (result) {
this._readStream.destroy();
this._promptFinished(result);
logger_base_1.AwesomeLoggerBase.changeKeyListener(undefined);
this.multiLogger['_children'].splice(0, this.multiLogger['_children'].length - 1);
this.resetViewAndShowResult();
this._promptFinished(result);
};
AwesomePromptBase.prototype.waitForUserInput = function () {
var _this = this;
var stdin = process.stdin;
// without this, we would only get streams once enter is pressed
stdin.setRawMode(true);
stdin.resume();
stdin.setEncoding('utf8');
this._readStream = stdin.on('data', function (key) {
// ctrl-c ( end of text )
if (key.toString() === '\u0003') {
process.exit();
}
_this.gotKey(key.toString());
});
logger_base_1.AwesomeLoggerBase.changeKeyListener(function (val) { return _this.gotKey(val); });
};

@@ -72,0 +61,0 @@ return AwesomePromptBase;

@@ -67,4 +67,3 @@ "use strict";

this._currentHighlightedRow++;
if (this._currentHighlightedRow - this.scrollAmount > awesome_logger_1.AwesomeLogger.maxLinesInTerminal - 2 &&
this.scrollAmount < this._options.length - awesome_logger_1.AwesomeLogger.maxLinesInTerminal) {
if (this._currentHighlightedRow - this.scrollAmount > awesome_logger_1.AwesomeLogger.maxLinesInTerminal - 4) {
this.scrollAmount++;

@@ -96,3 +95,2 @@ }

AwesomeTogglePromt.prototype.resetViewAndShowResult = function () {
var resultLog = new text_object_1.TextObject(' - Selected option(s): ', 'GRAY');
var result = new Array();

@@ -106,2 +104,3 @@ for (var i = 0; i < this._options.length; i++) {

}
var resultLog = new text_object_1.TextObject(" - Selected option" + (result.length > 1 ? 's' : '') + ": ", 'GRAY');
resultLog.append(result.join(', '), 'GREEN');

@@ -108,0 +107,0 @@ this.multiLogger.getChild(0).setText(resultLog);

import { TextObject } from '../../models/text-object';
export declare abstract class AwesomeLoggerBase {
private static currentKeyListener?;
static isInitialized: boolean;
scrollAmount: number;
private _lastLine;
protected _hasChanges: boolean;
private readonly _readStream;
constructor();
static changeKeyListener(listener?: (val: string) => any): void;
abstract getNextLine(): TextObject;

@@ -8,0 +12,0 @@ abstract hasChanges(): boolean;

@@ -13,3 +13,27 @@ "use strict";

ansi_utils_1.HIDE_CURSOR();
if (!AwesomeLoggerBase.isInitialized) {
AwesomeLoggerBase.isInitialized = true;
var stdin = process.stdin;
stdin.setRawMode(true);
stdin.resume();
stdin.setEncoding('utf8');
this._readStream = stdin.on('data', function (key) {
var _a;
// ctrl-c ( end of text )
if (key.toString() === '\u0003') {
process.exit();
}
(_a = AwesomeLoggerBase.currentKeyListener) === null || _a === void 0 ? void 0 : _a.call(AwesomeLoggerBase, key.toString());
});
}
}
AwesomeLoggerBase.changeKeyListener = function (listener) {
this.currentKeyListener = listener;
if (!this.currentKeyListener) {
process.stdin.pause();
}
else {
process.stdin.resume();
}
};
AwesomeLoggerBase.prototype.changed = function () {

@@ -39,2 +63,3 @@ this._hasChanges = true;

};
AwesomeLoggerBase.isInitialized = false;
return AwesomeLoggerBase;

@@ -41,0 +66,0 @@ }());

@@ -55,18 +55,3 @@ "use strict";

var a = awesome_logger_1.AwesomeLogger.prompt('toggle', {
options: [
'first',
'second',
'third',
'fourth',
'fifth',
'sixth',
'first',
'second',
'third',
'fourth',
'fifth',
'sixth',
'first',
'second'
]
options: ['first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'nineth', 'tenth']
});

@@ -73,0 +58,0 @@ a.result.then(function (x) {

{
"name": "awesome-logging",
"version": "0.0.8",
"version": "0.1.0",
"description": "Advanced logging messages, interactive prompts, loading animations and more in TypeScript",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc