Compare commits
51 Commits
Author | SHA1 | Date | |
---|---|---|---|
c9e92e9549 | |||
0309e037a0 | |||
872385dbc4 | |||
922591d45d | |||
a39a2bdfa8 | |||
93128628cc | |||
023b3ff377 | |||
8e3f65061a | |||
1f9bfcc856 | |||
04686b810f | |||
f9afc486f3 | |||
ce6bdb984c | |||
10fa0af94c | |||
0a3f6da174 | |||
9073d9a7f8 | |||
890cd463d5 | |||
186766df3d | |||
62ff7ec717 | |||
ca3286625d | |||
ff33c9597a | |||
65604d4ec0 | |||
f83c8feb3e | |||
2b7a4ff07a | |||
1c59952bb5 | |||
bb48d3cb04 | |||
64a555748e | |||
34fd838e80 | |||
b48b2a77b0 | |||
99c2c2e84f | |||
bf791d732c | |||
e5e7f00353 | |||
78bd0605aa | |||
f1e3ca6014 | |||
0712d47155 | |||
2a9b686e94 | |||
a9180878d5 | |||
4a1214a87f | |||
d85878713e | |||
9d65e37a60 | |||
5dd07e34ed | |||
ba7727dc55 | |||
7c85387c85 | |||
c978ada06c | |||
ca749d45b1 | |||
89efae2eb7 | |||
5da96c42c6 | |||
127476c86e | |||
7c1eb711da | |||
0edaa51679 | |||
db46fca769 | |||
824efb1fc8 |
26
.gitignore
vendored
26
.gitignore
vendored
@ -1,10 +1,20 @@
|
||||
node_modules/
|
||||
coverage/
|
||||
pages/
|
||||
public/
|
||||
|
||||
|
||||
npm-debug.log
|
||||
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
105
.gitlab-ci.yml
105
.gitlab-ci.yml
@ -1,38 +1,70 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .yarn/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
- pages
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
before_script:
|
||||
- pnpm install -g pnpm
|
||||
- pnpm install -g @shipzone/npmci
|
||||
- npmci npm prepare
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci test legacy
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command pnpm audit --audit-level=high --prod
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command pnpm audit --audit-level=high --dev
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
@ -40,32 +72,57 @@ testSTABLE:
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: trigger
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: pages
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command yarn global add npmpage
|
||||
- npmci command npmpage
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run buildDocs
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
- public
|
||||
allow_failure: true
|
||||
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["/npmextra.json"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"npmci": {
|
||||
"type": "object",
|
||||
"description": "settings for npmci"
|
||||
},
|
||||
"gitzone": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone",
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
29
README.md
29
README.md
@ -1,29 +0,0 @@
|
||||
# beautylog
|
||||
beautiful logging, TypeScript ready
|
||||
|
||||
## Availabililty
|
||||
[](https://www.npmjs.com/package/beautylog)
|
||||
[](https://GitLab.com/pushrocks/beautylog)
|
||||
[](https://github.com/pushrocks/beautylog)
|
||||
[](https://pushrocks.gitlab.io/beautylog/)
|
||||
|
||||
## Status for master
|
||||
[](https://GitLab.com/pushrocks/beautylog/commits/master)
|
||||
[](https://GitLab.com/pushrocks/beautylog/commits/master)
|
||||
[](https://www.npmjs.com/package/beautylog)
|
||||
[](https://david-dm.org/pushrocks/beautylog)
|
||||
[](https://www.bithound.io/github/pushrocks/beautylog/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/beautylog)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Quick Demo
|
||||
[](https://asciinema.org/a/46djsde96ecsho9wqibjx2zye)
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
|
||||
[](https://push.rocks)
|
16
dist/beautylog.classes.ora.d.ts
vendored
16
dist/beautylog.classes.ora.d.ts
vendored
@ -1,16 +0,0 @@
|
||||
import 'typings-global';
|
||||
export declare let oraActive: boolean;
|
||||
export declare let activeOra: Ora;
|
||||
export declare class Ora {
|
||||
state: string;
|
||||
private _oraObject;
|
||||
constructor(textArg: string, colorArg: string, startArg?: boolean);
|
||||
text(textArg: any): void;
|
||||
start(textArg?: string, colorArg?: string): void;
|
||||
end(): void;
|
||||
endOk(textArg: any): void;
|
||||
endError(textArg: any): void;
|
||||
pause(): void;
|
||||
stop(): void;
|
||||
}
|
||||
export declare let ora: Ora;
|
55
dist/beautylog.classes.ora.js
vendored
55
dist/beautylog.classes.ora.js
vendored
@ -1,55 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("typings-global");
|
||||
const plugins = require("./beautylog.plugins");
|
||||
const beautylog_log_helpers_1 = require("./beautylog.log.helpers");
|
||||
exports.oraActive = false; // when an Ora is active (e.g. start()) this is true
|
||||
class Ora {
|
||||
constructor(textArg, colorArg, startArg = false) {
|
||||
this._oraObject = plugins.ora({
|
||||
spinner: 'dots',
|
||||
text: textArg,
|
||||
color: colorArg
|
||||
});
|
||||
if (startArg) {
|
||||
this.start();
|
||||
}
|
||||
}
|
||||
text(textArg) {
|
||||
this._oraObject.text = textArg;
|
||||
}
|
||||
start(textArg, colorArg) {
|
||||
if (textArg) {
|
||||
this.text(textArg);
|
||||
}
|
||||
if (colorArg) {
|
||||
this._oraObject.color = colorArg;
|
||||
}
|
||||
exports.activeOra = this;
|
||||
exports.oraActive = true;
|
||||
this._oraObject.start();
|
||||
}
|
||||
end() {
|
||||
this._oraObject.stop();
|
||||
this._oraObject.clear();
|
||||
exports.activeOra = undefined;
|
||||
exports.oraActive = false;
|
||||
}
|
||||
endOk(textArg) {
|
||||
this.end();
|
||||
beautylog_log_helpers_1.logNode('ok', textArg);
|
||||
}
|
||||
endError(textArg) {
|
||||
this.end();
|
||||
beautylog_log_helpers_1.logNode('error', textArg);
|
||||
}
|
||||
pause() {
|
||||
this._oraObject.stop();
|
||||
}
|
||||
stop() {
|
||||
this.end();
|
||||
}
|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
|
||||
export declare let beautyConsole: {
|
||||
log: (logArg: any) => void;
|
||||
error: () => void;
|
||||
};
|
42
dist/beautylog.console.js
vendored
42
dist/beautylog.console.js
vendored
@ -1,42 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("typings-global");
|
||||
const beautylog_classes_ora_1 = require("./beautylog.classes.ora");
|
||||
let nativeLog = console.log;
|
||||
let nativeError = console.error;
|
||||
/**
|
||||
* routes the console to got through beautylog, so beautylog can take action before things are logged to console.
|
||||
*/
|
||||
let route = function (statusArg) {
|
||||
if (statusArg === true) {
|
||||
console.log = exports.beautyConsole.log;
|
||||
console.error = exports.beautyConsole.error;
|
||||
}
|
||||
else {
|
||||
console.log = nativeLog;
|
||||
}
|
||||
};
|
||||
exports.beautyConsole = {
|
||||
log: function (logArg) {
|
||||
if (beautylog_classes_ora_1.oraActive) {
|
||||
beautylog_classes_ora_1.activeOra.pause();
|
||||
nativeLog.apply(nativeLog, arguments);
|
||||
beautylog_classes_ora_1.activeOra.start();
|
||||
}
|
||||
else {
|
||||
nativeLog.apply(nativeLog, arguments);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
if (beautylog_classes_ora_1.oraActive) {
|
||||
beautylog_classes_ora_1.activeOra.pause();
|
||||
nativeLog.apply(nativeError, arguments);
|
||||
beautylog_classes_ora_1.activeOra.start();
|
||||
}
|
||||
else {
|
||||
nativeLog.apply(nativeError, arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
route(true);
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLmNvbnNvbGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9iZWF1dHlsb2cuY29uc29sZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUV2QixtRUFBOEQ7QUFDOUQsSUFBSSxTQUFTLEdBQUcsT0F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UFDdkMsaUNBQVMsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtRQUNyQixDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDSixTQUFTLENBQUMsS0FBSyxDQUFDLFdBQVcsRUFBRSxTQUFTLENBQUMsQ0FBQTtRQUMzQyxDQUFDO0lBQ0wsQ0FBQztDQUNKLENBQUE7QUFFRCxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUEifQ==
|
9
dist/beautylog.figlet.d.ts
vendored
9
dist/beautylog.figlet.d.ts
vendored
@ -1,9 +0,0 @@
|
||||
import 'typings-global';
|
||||
import plugins = require('./beautylog.plugins');
|
||||
export interface IFigletOptions {
|
||||
font?: string;
|
||||
color?: plugins.beautycolor.TColorName;
|
||||
cb?: any;
|
||||
}
|
||||
export declare let figlet: (textArg: string, optionsArg?: any) => Promise<{}>;
|
||||
export declare let figletSync: (textArg: string, optionsArg?: IFigletOptions) => boolean;
|
50
dist/beautylog.figlet.js
vendored
50
dist/beautylog.figlet.js
vendored
@ -1,50 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("typings-global");
|
||||
const plugins = require("./beautylog.plugins");
|
||||
let defaultOptions = {
|
||||
font: 'Star Wars',
|
||||
color: 'green',
|
||||
cb: function () { }
|
||||
};
|
||||
exports.figlet = function (textArg, optionsArg) {
|
||||
let done = plugins.q.defer();
|
||||
let mergeOptions = plugins.lodash.cloneDeep(defaultOptions);
|
||||
let options = plugins.lodash.assign(mergeOptions, optionsArg);
|
||||
plugins.figlet(textArg, {
|
||||
font: options.font,
|
||||
horizontalLayout: 'default',
|
||||
verticalLayout: 'default'
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
console.log('Something went wrong...');
|
||||
console.dir(err);
|
||||
return;
|
||||
}
|
||||
console.log(colorFiglet(data, options.color));
|
||||
options.cb();
|
||||
done.resolve();
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
exports.figletSync = function (textArg, optionsArg) {
|
||||
let mergeOptions = plugins.lodash.cloneDeep(defaultOptions);
|
||||
let options = plugins.lodash.assign(mergeOptions, optionsArg);
|
||||
let figletString = plugins.figlet.textSync(textArg, {
|
||||
font: options.font,
|
||||
horizontalLayout: 'default',
|
||||
verticalLayout: 'default'
|
||||
});
|
||||
console.log(colorFiglet(figletString, options.color));
|
||||
return true;
|
||||
};
|
||||
let colorFiglet = (figletStringArg, colorArg) => {
|
||||
let figletArray = figletStringArg.split('\n');
|
||||
let figletStringCombined = '';
|
||||
for (let figletRow of figletArray) {
|
||||
figletRow = plugins.beautycolor.coloredString(figletRow, colorArg);
|
||||
figletStringCombined = figletStringCombined + figletRow + '\n';
|
||||
}
|
||||
return figletStringCombined;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLmZpZ2xldC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2JlYXV0eWxvZy5maWdsZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwwQkFBdUI7QUFDdkIsK0NBQStDO0FBUS9DLElBQUksY0FBYyxHQUFtQjtJQUNqQyxJQUFJLEVBQUUsV0FBVztJQUNqQixLQUFLLEVBQUUsT0FBTztJQUNkLEVBQUUsRUFBRSxjQUFZLENBQUM7Q0FDcEIsQ0FBQTtBQUVVLFFBQUEsTUFBTSxHQUFHLFVBQVMsT0FBZSxFQUFFLFVBQVc7SUFDckQsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtJQUM1QixJQUFJLFlBQVksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLFNBQVMsQ0FBQyxjQUFjLENBQUMsQ0FBQTtJQUMzRCxJQUFJLE9BQU8sR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxZQUFZLEVBQU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BTyxDQUFDLElBQUk7UUFDbEIsZ0JBQWdCLEVBQUUsU0FBUztRQUMzQixjQUFjLEVBQUUsU0FBUztLQUM1QixDQUFDLENBQUE7SUFDRixPQUFPLENBQUMsR0FBRyxDQUFDLFdBQVcsQ0FBQyxZQUFZLEVBQUUsT0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUE7SUFDckQsTUFBTSxDQUFDLElBQUksQ0FBQTtBQUNmLENBQUMsQ0FBQTtBQUVELElBQUksV0FBVyxHQUFHLENBQUMsZUFBZSxFQUFFLFFBQXdDO0lBQ3hFLElBQUksV0FBVyxHQUFHLGVBQWUsQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUE7SUFDN0MsSUFBSSxvQkFBb0IsR0FBRyxFQUFFLENBQUE7SUFDN0IsR0FBRyxDQUFDLENBQUMsSUFBSSxTQUFTLElBQUksV0FBWSxDQUFDLENBQUMsQ0FBQztRQUNqQyxTQUFTLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxhQUFhLENBQUMsU0FBUyxFQUFFLFFBQVEsQ0FBQyxDQUFBO1FBQ2xFLG9CQUFvQixHQUFHLG9CQUFvQixHQUFHLFNBQVMsR0FBRyxJQUFJLENBQUE7SUFDbEUsQ0FBQztJQUNELE1BQU0sQ0FBQyxvQkFBb0IsQ0FBQTtBQUMvQixDQUFDLENBQUEifQ==
|
52
dist/beautylog.log.d.ts
vendored
52
dist/beautylog.log.d.ts
vendored
@ -1,52 +0,0 @@
|
||||
import 'typings-global';
|
||||
/**
|
||||
* logs an info to console
|
||||
* @param logText
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export declare let log: (logText: any) => void;
|
||||
export declare let info: (logText: any) => void;
|
||||
/**
|
||||
* logs an 'OK!' message to console
|
||||
* @param logText
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export declare let ok: (logText: any) => void;
|
||||
/**
|
||||
* logs a success to console
|
||||
* @param logText string to log as error
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export declare let success: (logText: any) => void;
|
||||
/**
|
||||
* logs a 'warn:' message to console
|
||||
* @param logText string to log as error
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export declare let warn: (logText: any) => void;
|
||||
/**
|
||||
* logs an error to console
|
||||
* @param logText
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export declare let error: (logText: any) => void;
|
||||
/**
|
||||
* logs an directory to console
|
||||
* @param logText
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export declare let dir: (logText: any) => void;
|
||||
/**
|
||||
* note
|
||||
*/
|
||||
export declare let note: (logText: any) => void;
|
||||
/**
|
||||
* creates a new empty line
|
||||
* @param linesArg
|
||||
* @returns void
|
||||
*/
|
||||
export declare let newLine: (linesArg?: number) => void;
|
||||
/**
|
||||
* logs a reduced log that only logs changes of consequential log messages
|
||||
*/
|
||||
export declare let logReduced: (logTextArg: string, repeatEveryTimesArg?: number) => void;
|
8
dist/beautylog.log.helpers.d.ts
vendored
8
dist/beautylog.log.helpers.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* @param logText
|
||||
* @param logType
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export declare let internalLog: (logType?: string, logText?: string) => void;
|
||||
export declare let logNode: (logType: string, logText: string) => boolean;
|
111
dist/beautylog.log.helpers.js
vendored
111
dist/beautylog.log.helpers.js
vendored
File diff suppressed because one or more lines are too long
87
dist/beautylog.log.js
vendored
87
dist/beautylog.log.js
vendored
@ -1,87 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("typings-global");
|
||||
const beautylog_log_helpers_1 = require("./beautylog.log.helpers");
|
||||
/**
|
||||
* logs an info to console
|
||||
* @param logText
|
||||
* @returns {boolean}
|
||||
*/
|
||||
exports.log = (logText) => {
|
||||
return beautylog_log_helpers_1.internalLog('log', logText);
|
||||
};
|
||||
exports.info = (logText) => {
|
||||
return beautylog_log_helpers_1.internalLog('info', logText);
|
||||
};
|
||||
/**
|
||||
* logs an 'OK!' message to console
|
||||
* @param logText
|
||||
* @returns {boolean}
|
||||
*/
|
||||
exports.ok = (logText) => {
|
||||
return beautylog_log_helpers_1.internalLog('ok', logText);
|
||||
};
|
||||
/**
|
||||
* logs a success to console
|
||||
* @param logText string to log as error
|
||||
* @returns {boolean}
|
||||
*/
|
||||
exports.success = (logText) => {
|
||||
return beautylog_log_helpers_1.internalLog('success', logText);
|
||||
};
|
||||
/**
|
||||
* logs a 'warn:' message to console
|
||||
* @param logText string to log as error
|
||||
* @returns {boolean}
|
||||
*/
|
||||
exports.warn = (logText) => {
|
||||
return beautylog_log_helpers_1.internalLog('warn', logText);
|
||||
};
|
||||
/**
|
||||
* logs an error to console
|
||||
* @param logText
|
||||
* @returns {boolean}
|
||||
*/
|
||||
exports.error = (logText) => {
|
||||
return beautylog_log_helpers_1.internalLog('error', logText);
|
||||
};
|
||||
/**
|
||||
* logs an directory to console
|
||||
* @param logText
|
||||
* @returns {boolean}
|
||||
*/
|
||||
exports.dir = (logText) => {
|
||||
return beautylog_log_helpers_1.internalLog('dir', logText);
|
||||
};
|
||||
/**
|
||||
* note
|
||||
*/
|
||||
exports.note = (logText) => {
|
||||
return beautylog_log_helpers_1.internalLog('note', logText);
|
||||
};
|
||||
/**
|
||||
* creates a new empty line
|
||||
* @param linesArg
|
||||
* @returns void
|
||||
*/
|
||||
exports.newLine = (linesArg = 1) => {
|
||||
for (let i = 0; i < linesArg; i++) {
|
||||
console.log('\n');
|
||||
}
|
||||
};
|
||||
/**
|
||||
* logs a reduced log that only logs changes of consequential log messages
|
||||
*/
|
||||
exports.logReduced = (logTextArg, repeatEveryTimesArg = 0) => {
|
||||
if (logTextArg === previousMessage && (repeatEveryTimesArg === 0 || sameMessageCounter !== repeatEveryTimesArg)) {
|
||||
sameMessageCounter++;
|
||||
}
|
||||
else {
|
||||
sameMessageCounter = 0;
|
||||
previousMessage = logTextArg;
|
||||
exports.log(logTextArg);
|
||||
}
|
||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sQ0FBQyxDQUFBO0lBQ25CLENBQUM7QUFDTCxDQUFDLENBQUE7QUFDRCxJQUFJLGVBQWUsR0FBVyxFQUFFLENBQUE7QUFDaEMsSUFBSSxrQkFBa0IsR0FBVyxDQUFDLENBQUEifQ==
|
8
dist/beautylog.plugins.d.ts
vendored
8
dist/beautylog.plugins.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
import 'typings-global';
|
||||
import * as beautycolor from 'beautycolor';
|
||||
import * as lodash from 'lodash';
|
||||
import * as smartenv from 'smartenv';
|
||||
import * as q from 'smartq';
|
||||
declare let figlet: any;
|
||||
declare let ora: any;
|
||||
export { beautycolor, lodash, smartenv, q, figlet, ora };
|
16
dist/beautylog.plugins.js
vendored
16
dist/beautylog.plugins.js
vendored
@ -1,16 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("typings-global");
|
||||
const beautycolor = require("beautycolor");
|
||||
exports.beautycolor = beautycolor;
|
||||
const lodash = require("lodash");
|
||||
exports.lodash = lodash;
|
||||
const smartenv = require("smartenv");
|
||||
exports.smartenv = smartenv;
|
||||
const q = require("smartq");
|
||||
exports.q = q;
|
||||
let figlet = require('figlet');
|
||||
exports.figlet = figlet;
|
||||
let ora = require('ora');
|
||||
exports.ora = ora;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9iZWF1dHlsb2cucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUV2QiwyQ0FBMEM7QUFRdEMsa0NBQVc7QUFQZixpQ0FBZ0M7QUFRNUIsd0JBQU07QUFQVixxQ0FBb0M7QUFRaEMsNEJBQVE7QUFQWiw0QkFBMkI7QUFRdkIsY0FBQztBQVBMLElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQTtBQVExQix3QkFBTTtBQVBWLElBQUksR0FBRyxHQUFHLE9BQU8sQ0FBQyxLQUFLLENBQUMsQ0FBQTtBQVFwQixrQkFBRyJ9
|
4
dist/beautylog.register.d.ts
vendored
4
dist/beautylog.register.d.ts
vendored
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* registers a remote
|
||||
*/
|
||||
export declare let registerRemote: (remoteArg: any) => void;
|
10
dist/beautylog.register.js
vendored
10
dist/beautylog.register.js
vendored
@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const beautylog_remote_1 = require("./beautylog.remote");
|
||||
/**
|
||||
* registers a remote
|
||||
*/
|
||||
exports.registerRemote = (remoteArg) => {
|
||||
beautylog_remote_1.remoteArray.push(remoteArg);
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLnJlZ2lzdGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvYmVhdXR5bG9nLnJlZ2lzdGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEseURBQThDO0FBRTlDOztHQUVHO0FBQ1EsUUFBQSxjQUFjLEdBQUcsQ0FBQyxTQUFjO0lBQ3ZDLDhCQUFXLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFBO0FBQy9CLENBQUMsQ0FBQSJ9
|
8
dist/beautylog.remote.d.ts
vendored
8
dist/beautylog.remote.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
export interface ILogMethod {
|
||||
(logType: string, logMessage: string): void;
|
||||
}
|
||||
export interface IBeautyRemote {
|
||||
log: ILogMethod;
|
||||
}
|
||||
export declare let remoteArray: IBeautyRemote[];
|
||||
export declare let remoteLog: (logType: string, logMessage: string) => void;
|
9
dist/beautylog.remote.js
vendored
9
dist/beautylog.remote.js
vendored
@ -1,9 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.remoteArray = [];
|
||||
exports.remoteLog = (logType, logMessage) => {
|
||||
for (let beautyremote of exports.remoteArray) {
|
||||
beautyremote.log(logType, logMessage);
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLnJlbW90ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2JlYXV0eWxvZy5yZW1vdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFVVyxRQUFBLFdBQVcsR0FBb0IsRUFBRSxDQUFBO0FBRWpDLFFBQUEsU0FBUyxHQUFHLENBQUMsT0FBZSxFQUFFLFVBQWtCO0lBQ3pELEdBQUcsQ0FBQyxDQUFDLElBQUksWUFBWSxJQUFJLG1CQUFXLENBQUMsQ0FBQyxDQUFDO1FBQ3JDLFlBQVksQ0FBQyxHQUFHLENBQUMsT0FBTyxFQUFFLFVBQVUsQ0FBQyxDQUFBO0lBQ3ZDLENBQUM7QUFDSCxDQUFDLENBQUEifQ==
|
6
dist/index.d.ts
vendored
6
dist/index.d.ts
vendored
@ -1,6 +0,0 @@
|
||||
import 'typings-global';
|
||||
import './beautylog.console';
|
||||
export { ora } from './beautylog.classes.ora';
|
||||
export { dir, error, info, log, logReduced, note, ok, success, warn, newLine } from './beautylog.log';
|
||||
export { figlet, figletSync } from './beautylog.figlet';
|
||||
export { registerRemote } from './beautylog.register';
|
25
dist/index.js
vendored
25
dist/index.js
vendored
@ -1,25 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("typings-global");
|
||||
require("./beautylog.console");
|
||||
// export classes
|
||||
var beautylog_classes_ora_1 = require("./beautylog.classes.ora");
|
||||
exports.ora = beautylog_classes_ora_1.ora;
|
||||
// export methods
|
||||
var beautylog_log_1 = require("./beautylog.log");
|
||||
exports.dir = beautylog_log_1.dir;
|
||||
exports.error = beautylog_log_1.error;
|
||||
exports.info = beautylog_log_1.info;
|
||||
exports.log = beautylog_log_1.log;
|
||||
exports.logReduced = beautylog_log_1.logReduced;
|
||||
exports.note = beautylog_log_1.note;
|
||||
exports.ok = beautylog_log_1.ok;
|
||||
exports.success = beautylog_log_1.success;
|
||||
exports.warn = beautylog_log_1.warn;
|
||||
exports.newLine = beautylog_log_1.newLine;
|
||||
var beautylog_figlet_1 = require("./beautylog.figlet");
|
||||
exports.figlet = beautylog_figlet_1.figlet;
|
||||
exports.figletSync = beautylog_figlet_1.figletSync;
|
||||
var beautylog_register_1 = require("./beautylog.register");
|
||||
exports.registerRemote = beautylog_register_1.registerRemote;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QiwrQkFBNEI7QUFHNUIsaUJBQWlCO0FBQ2pCLGlFQUE2QztBQUFwQyxzQ0FBQSxHQUFHLENBQUE7QUFFWixpQkFBaUI7QUFDakIsaURBQXFHO0FBQTVGLDhCQUFBLEdBQUcsQ0FBQTtBQUFFLGdDQUFBLEtBQUssQ0FBQTtBQUFFLCtCQUFBLElBQUksQ0FBQTtBQUFFLDhCQUFBLEdBQUcsQ0FBQTtBQUFFLHFDQUFBLFVBQVUsQ0FBQTtBQUFFLCtCQUFBLElBQUksQ0FBQTtBQUFFLDZCQUFBLEVBQUUsQ0FBQTtBQUFFLGtDQUFBLE9BQU8sQ0FBQTtBQUFFLCtCQUFBLElBQUksQ0FBQTtBQUFFLGtDQUFBLE9BQU8sQ0FBQTtBQUM1RSx1REFBdUQ7QUFBOUMsb0NBQUEsTUFBTSxDQUFBO0FBQUUsd0NBQUEsVUFBVSxDQUFBO0FBQzNCLDJEQUFxRDtBQUE1Qyw4Q0FBQSxjQUFjLENBQUEifQ==
|
@ -1,13 +1,16 @@
|
||||
# beautylog
|
||||
|
||||
beautiful logging, TypeScript ready
|
||||
|
||||
## Availabililty
|
||||
|
||||
[](https://www.npmjs.com/package/beautylog)
|
||||
[](https://GitLab.com/pushrocks/beautylog)
|
||||
[](https://github.com/pushrocks/beautylog)
|
||||
[](https://pushrocks.gitlab.io/beautylog/)
|
||||
|
||||
## Status for master
|
||||
|
||||
[](https://GitLab.com/pushrocks/beautylog/commits/master)
|
||||
[](https://GitLab.com/pushrocks/beautylog/commits/master)
|
||||
[](https://www.npmjs.com/package/beautylog)
|
||||
@ -19,49 +22,53 @@ beautiful logging, TypeScript ready
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Quick Demo
|
||||
|
||||
[](https://asciinema.org/a/46djsde96ecsho9wqibjx2zye)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
```javascript
|
||||
beautylog.log('some log message') // normal console log message
|
||||
beautylog.info('some log message') // info console log message
|
||||
beautylog.ok('some log message') // ok console log message
|
||||
beautylog.warn('some log message') // warn console log message
|
||||
beautylog.success('some success message') // success console log message
|
||||
beautylog.error('some error message') // error console log message
|
||||
beautylog.log('some log message'); // normal console log message
|
||||
beautylog.info('some log message'); // info console log message
|
||||
beautylog.ok('some log message'); // ok console log message
|
||||
beautylog.warn('some log message'); // warn console log message
|
||||
beautylog.success('some success message'); // success console log message
|
||||
beautylog.error('some error message'); // error console log message
|
||||
```
|
||||
|
||||
### Ora Integration
|
||||
|
||||
beautylog wraps the excellent ora module from npm to better work with beautylog. In general that means that you can log persistent messages WHILE you are actually having an active Ora object. beautylog handles all the fuss for you.
|
||||
|
||||
```javascript
|
||||
beautylog.ora.start('Hi, this is some text!', 'blue')
|
||||
beautylog.info('some persistent text') //does not disturb ora
|
||||
console.log('something') // even this works because console.log is monkeypatched by beautylog
|
||||
beautylog.ora.text('some updated text') // switches the text
|
||||
beautylog.ora.stop()
|
||||
beautylog.ora.start('Hi, this is some text!', 'blue');
|
||||
beautylog.info('some persistent text'); //does not disturb ora
|
||||
console.log('something'); // even this works because console.log is monkeypatched by beautylog
|
||||
beautylog.ora.text('some updated text'); // switches the text
|
||||
beautylog.ora.stop();
|
||||
```
|
||||
|
||||
## Centralized remote logging
|
||||
|
||||
Beautylog makes it easy to have all your node applications log to a remote location.
|
||||
|
||||
```javascript
|
||||
import { Loggly } from 'beautyremote'
|
||||
import { Loggly } from 'beautyremote';
|
||||
let myLogglyRemote = new Loggly({
|
||||
token: 'my_super_long_token_here'
|
||||
})
|
||||
beautylog.registerRemote(myLogglyRemote)
|
||||
token: 'my_super_long_token_here',
|
||||
});
|
||||
beautylog.registerRemote(myLogglyRemote);
|
||||
```
|
||||
|
||||
> Note: Beautylog monkeypatches all console log methods.
|
||||
There is no need to change anything in your code.
|
||||
Everything that is getting logged to your console by node will get logged to a remote as well.
|
||||
> There is no need to change anything in your code.
|
||||
> Everything that is getting logged to your console by node will get logged to a remote as well.
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
|
||||
[](https://push.rocks)
|
||||
|
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Push.Rocks
|
||||
Copyright (c) 2015 Lossless GmbH
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
@ -1,7 +1,28 @@
|
||||
{
|
||||
"npmci": {
|
||||
"globalNpmTools": [
|
||||
"npmts"
|
||||
]
|
||||
"globalNpmTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "smartlog-destination-local",
|
||||
"description": "a smartlog destination targeting the local console",
|
||||
"npmPackagename": "@push.rocks/smartlog-destination-local",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"logging",
|
||||
"console log",
|
||||
"log management",
|
||||
"developer tools",
|
||||
"local logging",
|
||||
"console output"
|
||||
]
|
||||
}
|
||||
},
|
||||
"tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"mode":"default",
|
||||
"coveralls":true
|
||||
}
|
79
package.json
79
package.json
@ -1,50 +1,59 @@
|
||||
{
|
||||
"name": "beautylog",
|
||||
"version": "6.1.10",
|
||||
"description": "beautiful logging, TypeScript ready",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"name": "@push.rocks/smartlog-destination-local",
|
||||
"private": false,
|
||||
"version": "9.0.2",
|
||||
"description": "a smartlog destination targeting the local console",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(npmts)",
|
||||
"testbrowser": "(npm test) && (node testbrowser.js)",
|
||||
"gitsetup": "(git config push.followTags true)",
|
||||
"push": "(git push origin master && git push origin release && git push --follow-tags)",
|
||||
"reinstall": "(rm -r node_modules && npm install)",
|
||||
"release": "(npm test) && (git pull origin master && npm version patch && git checkout release && git merge master && git checkout master && npm run push)",
|
||||
"update": "(git checkout master && git pull origin master) && (npm install)",
|
||||
"upgrade": "(npm run update) && (ncu upgradeAll && npm install)"
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild --web)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitlab.com/pushrocks/beautylog.git"
|
||||
"url": "https://code.foss.global/push.rocks/smartlog-destination-local.git"
|
||||
},
|
||||
"keywords": [
|
||||
"log",
|
||||
"color",
|
||||
"console",
|
||||
"beautiful"
|
||||
"logging",
|
||||
"console log",
|
||||
"log management",
|
||||
"developer tools",
|
||||
"local logging",
|
||||
"console output"
|
||||
],
|
||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
||||
"author": "Lossless GmbH <hello@lossless.com> (https://lossless.com)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/pushrocks/beautylog/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/beautylog",
|
||||
"homepage": "https://code.foss.global/push.rocks/smartlog-destination-local",
|
||||
"dependencies": {
|
||||
"@types/lodash": "^4.14.55",
|
||||
"beautycolor": "^1.0.7",
|
||||
"figlet": "^1.2.0",
|
||||
"lodash": "^4.17.4",
|
||||
"ora": "^1.1.0",
|
||||
"smartenv": "^2.0.0",
|
||||
"smartq": "^1.1.1",
|
||||
"typings-global": "^1.0.14"
|
||||
"@push.rocks/consolecolor": "^2.0.1",
|
||||
"@push.rocks/smartlog-interfaces": "^3.0.0",
|
||||
"@push.rocks/smartpromise": "^4.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"beautyremote": "^1.0.5",
|
||||
"qenv": "^1.1.3",
|
||||
"smartchai": "^1.0.3",
|
||||
"smartdelay": "^1.0.1",
|
||||
"tapbundle": "^1.0.5"
|
||||
}
|
||||
}
|
||||
"@git.zone/tsbuild": "^2.1.66",
|
||||
"@git.zone/tsrun": "^1.2.42",
|
||||
"@git.zone/tstest": "^1.0.74",
|
||||
"@push.rocks/tapbundle": "^5.0.8",
|
||||
"@types/node": "^20.4.1"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"type": "module",
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
5009
pnpm-lock.yaml
generated
Normal file
5009
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
||||
|
111
readme.md
Normal file
111
readme.md
Normal file
@ -0,0 +1,111 @@
|
||||
# @push.rocks/smartlog-destination-local
|
||||
a smartlog destination targeting the local console
|
||||
|
||||
## Install
|
||||
To use `@push.rocks/smartlog-destination-local` in your project, you need to install it via npm. You can do this by running:
|
||||
|
||||
```bash
|
||||
npm install @push.rocks/smartlog-destination-local --save
|
||||
```
|
||||
|
||||
This command adds `@push.rocks/smartlog-destination-local` to your project's dependencies and enables you to start implementing its features in your application.
|
||||
|
||||
## Usage
|
||||
|
||||
The `@push.rocks/smartlog-destination-local` package provides a way to easily log messages to the local console with support for color coding and structured message formats. It is especially useful when combined with the `@push.rocks/smartlog` package to create a powerful logging solution that is both visually informative and structured for better logging practices.
|
||||
|
||||
### Importing and Setting Up
|
||||
|
||||
First, make sure to import the package where you intend to use it:
|
||||
|
||||
```typescript
|
||||
import { DestinationLocal } from '@push.rocks/smartlog-destination-local';
|
||||
```
|
||||
|
||||
Next, create an instance of `DestinationLocal`:
|
||||
|
||||
```typescript
|
||||
const localLogDestination = new DestinationLocal();
|
||||
```
|
||||
|
||||
### Logging Messages
|
||||
|
||||
The primary feature of `@push.rocks/smartlog-destination-local` is to log messages to the console. This can be done by preparing a log package and using the `handleLog` method.
|
||||
|
||||
#### Example Log Message
|
||||
|
||||
```typescript
|
||||
import type { ILogPackage } from '@push.rocks/smartlog-interfaces';
|
||||
|
||||
const logPackage: ILogPackage = {
|
||||
timestamp: Date.now(),
|
||||
type: 'log', // or 'error', 'warn', etc. depending on the nature of the message
|
||||
level: 'info', // determines the visibility and importance of the log
|
||||
context: {
|
||||
company: 'Your Company',
|
||||
companyunit: 'Your Unit',
|
||||
containerName: 'Your Container',
|
||||
environment: 'development',
|
||||
runtime: 'node',
|
||||
zone: 'Your Zone'
|
||||
},
|
||||
message: 'This is a test log message.', // the actual message
|
||||
correlation: {
|
||||
id: 'uniqueId', // useful for tracing logs
|
||||
type: 'requestId'
|
||||
},
|
||||
};
|
||||
|
||||
// Using the instance to log the message
|
||||
localLogDestination.handleLog(logPackage);
|
||||
```
|
||||
|
||||
This will output a structured, color-coded log message to your console, making it easier to differentiate between various log levels and to understand the context of the log messages at a glance.
|
||||
|
||||
### Log Reduction
|
||||
|
||||
For scenarios where repeated log messages may clutter your log output, `@push.rocks/smartlog-destination-local` offers a `logReduced` method. This method will throttle the output of identical consecutive messages according to the settings you provide.
|
||||
|
||||
#### Reducing Log Output
|
||||
|
||||
```typescript
|
||||
// Log a message repeatedly, e.g., in a loop
|
||||
for (let i = 0; i < 100; i++) {
|
||||
localLogDestination.logReduced('Repeated message', 5); // only logs every 5th identical message
|
||||
}
|
||||
```
|
||||
|
||||
### Adding New Lines
|
||||
|
||||
You may want to improve the readability of your logs by inserting blank lines. This can be easily achieved:
|
||||
|
||||
```typescript
|
||||
localLogDestination.newLine(2); // Inserts two empty lines in the log output
|
||||
```
|
||||
|
||||
### Advanced Use Cases
|
||||
|
||||
The `@push.rocks/smartlog-destination-local` package is flexible and integrates seamlessly with other logging and monitoring solutions. It can be extended or customized to fit more complex logging requirements, such as filtering logs based on environment, enhancing log messages with additional metadata, or integrating with remote logging services for centralized log management.
|
||||
|
||||
### Conclusion
|
||||
|
||||
`@push.rocks/smartlog-destination-local` serves as a robust, easy-to-use solution for enhancing your application's logging capabilities. By following the examples and using the provided methods, you can quickly implement effective logging practices that improve debugging, monitoring, and analysis of your application's behavior in development and production environments.
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||
|
||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||
|
||||
### Trademarks
|
||||
|
||||
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Registered at District court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +0,0 @@
|
||||
<head>
|
||||
<script async src="browserified/index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
@ -1,4 +0,0 @@
|
||||
var beautylog = require("./index.js");
|
||||
console.log("*** start browser console test (Might look weird in OS console and travis log...) ***");
|
||||
beautylog.log("hello");
|
||||
console.log("*** end browser console test ***");
|
112
test/test.ts
112
test/test.ts
@ -1,85 +1,49 @@
|
||||
import { tap, expect } from 'tapbundle'
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
|
||||
import beautylog = require('../dist/index')
|
||||
import * as beautyremote from 'beautyremote'
|
||||
import * as smartlogDesinationLocal from '../ts/index.js';
|
||||
import type { ILogContext } from '@push.rocks/smartlog-interfaces';
|
||||
|
||||
import * as qenv from 'qenv'
|
||||
let testQenv = new qenv.Qenv(process.cwd(), process.cwd() + '/.nogit')
|
||||
const testLogContext: ILogContext = {
|
||||
company: 'Lossless GmbH',
|
||||
companyunit: 'Lossless.Cloud',
|
||||
containerName: 'gitlabci',
|
||||
environment: 'staging',
|
||||
runtime: 'node',
|
||||
zone: 'shipzone',
|
||||
};
|
||||
|
||||
import * as smartdelay from 'smartdelay'
|
||||
let testLocalInstance: smartlogDesinationLocal.DestinationLocal;
|
||||
|
||||
tap.test('.registerRemote should accept a beautyremote', async () => {
|
||||
let myRemote = new beautyremote.Loggly({
|
||||
token: process.env.LOGGLY_TOKEN
|
||||
})
|
||||
beautylog.registerRemote(myRemote)
|
||||
})
|
||||
tap.test('should create a valid instance of DestinationLocal', async () => {
|
||||
testLocalInstance = new smartlogDesinationLocal.DestinationLocal();
|
||||
expect(testLocalInstance).toBeInstanceOf(smartlogDesinationLocal.DestinationLocal);
|
||||
});
|
||||
|
||||
tap.test('.log(message) should print a blue Dir message', async () => {
|
||||
beautylog.log('beautylog.log(), with normal logText, without logType')
|
||||
})
|
||||
|
||||
tap.test('.dir(message) should print a blue Dir message', async () => {
|
||||
beautylog.dir('beautylog.dir(), with normal logText, without logType')
|
||||
})
|
||||
|
||||
tap.test('.error(message) should print a red error message', async () => {
|
||||
beautylog.error('beautylog.error(), with normal logText, without logType')
|
||||
})
|
||||
|
||||
tap.test('.figlet should print nice fonts to console in yellow', async () => {
|
||||
return beautylog.figlet('Async!', { font: 'Star Wars', color: 'orange' })
|
||||
})
|
||||
|
||||
tap.test('.figletSync should print nice fonts to console in yellow', async () => {
|
||||
beautylog.figletSync('Sync!', { font: 'Star Wars', color: 'blue' })
|
||||
})
|
||||
|
||||
tap.test('.info(message) should display a purple info message', async () => {
|
||||
beautylog.info('beautylog.dir(), with normal logText, without logType')
|
||||
})
|
||||
testLocalInstance.handleLog({
|
||||
timestamp: Date.now(),
|
||||
type: 'log',
|
||||
level: 'info',
|
||||
context: testLogContext,
|
||||
message: 'this is a info log message',
|
||||
correlation: {
|
||||
id: '123',
|
||||
type: 'none',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('.logReduced(message) should only log two messages', async () => {
|
||||
beautylog.logReduced('Message 1')
|
||||
beautylog.logReduced('Message 1')
|
||||
beautylog.logReduced('Message 1')
|
||||
beautylog.logReduced('Message 1')
|
||||
beautylog.logReduced('Message 2')
|
||||
beautylog.logReduced('Message 2')
|
||||
})
|
||||
|
||||
tap.test('.ok(message) should display a green ok message', async () => {
|
||||
beautylog.ok('beautylog.ok() works!')
|
||||
})
|
||||
testLocalInstance.logReduced('Message 1');
|
||||
testLocalInstance.logReduced('Message 1');
|
||||
testLocalInstance.logReduced('Message 1');
|
||||
testLocalInstance.logReduced('Message 1');
|
||||
testLocalInstance.logReduced('Message 2');
|
||||
testLocalInstance.logReduced('Message 2');
|
||||
});
|
||||
|
||||
tap.test('.newLine(number) create specified amount of new lines', async () => {
|
||||
beautylog.newLine(1)
|
||||
})
|
||||
testLocalInstance.newLine(1);
|
||||
});
|
||||
|
||||
tap.test('.ora(text,color) should display, update, and end a message', async () => {
|
||||
beautylog.ora.start('This is a test text', 'green')
|
||||
await smartdelay.delayFor(2000)
|
||||
beautylog.ora.text('updated text!')
|
||||
await smartdelay.delayFor(2000)
|
||||
beautylog.info('another log message that uses the normal log function')
|
||||
await smartdelay.delayFor(2000)
|
||||
beautylog.ora.endOk('Allright, ora works!')
|
||||
})
|
||||
|
||||
tap.test('.ora(text,color) should display an error message when ended with error', async () => {
|
||||
beautylog.ora.start('This is another test text', 'green')
|
||||
await smartdelay.delayFor(2000)
|
||||
beautylog.ora.endError('Allright, ora displays an error!')
|
||||
})
|
||||
|
||||
tap.test('.success(message) should display an orange warn message', async () => {
|
||||
beautylog.success('beautylog.success() works!')
|
||||
})
|
||||
|
||||
tap.test('.warn should display a orange warn message', async () => {
|
||||
beautylog.warn('beautylog.warn() works!')
|
||||
})
|
||||
|
||||
tap.test('.note should display a pink note', async () => {
|
||||
beautylog.note('beautylog.note() works!')
|
||||
})
|
||||
tap.start();
|
||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartlog-destination-local',
|
||||
version: '9.0.2',
|
||||
description: 'a smartlog destination targeting the local console'
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
import 'typings-global'
|
||||
import * as plugins from './beautylog.plugins'
|
||||
import { logNode } from './beautylog.log.helpers'
|
||||
|
||||
export let oraActive: boolean = false // when an Ora is active (e.g. start()) this is true
|
||||
export let activeOra: Ora // points to the currently active Ora object
|
||||
|
||||
export class Ora {
|
||||
state: string
|
||||
private _oraObject
|
||||
constructor(textArg: string, colorArg: string, startArg: boolean = false) {
|
||||
this._oraObject = plugins.ora({
|
||||
spinner: 'dots',
|
||||
text: textArg,
|
||||
color: colorArg
|
||||
})
|
||||
if (startArg) {
|
||||
this.start()
|
||||
}
|
||||
}
|
||||
text(textArg) {
|
||||
this._oraObject.text = textArg
|
||||
}
|
||||
|
||||
start(textArg?: string, colorArg?: string) {
|
||||
if (textArg) { this.text(textArg) }
|
||||
if (colorArg) { this._oraObject.color = colorArg }
|
||||
activeOra = this
|
||||
oraActive = true
|
||||
this._oraObject.start()
|
||||
}
|
||||
end() {
|
||||
this._oraObject.stop()
|
||||
this._oraObject.clear()
|
||||
activeOra = undefined
|
||||
oraActive = false
|
||||
}
|
||||
endOk(textArg) {
|
||||
this.end()
|
||||
logNode('ok', textArg)
|
||||
}
|
||||
endError(textArg) {
|
||||
this.end()
|
||||
logNode('error', textArg)
|
||||
}
|
||||
pause() {
|
||||
this._oraObject.stop()
|
||||
}
|
||||
stop() { // alias for end
|
||||
this.end()
|
||||
}
|
||||
}
|
||||
|
||||
export let ora = new Ora('init...', 'blue', false)
|
@ -1,40 +0,0 @@
|
||||
import 'typings-global'
|
||||
import plugins = require('./beautylog.plugins')
|
||||
import { activeOra, oraActive } from './beautylog.classes.ora'
|
||||
let nativeLog = console.log
|
||||
let nativeError = console.error
|
||||
|
||||
/**
|
||||
* routes the console to got through beautylog, so beautylog can take action before things are logged to console.
|
||||
*/
|
||||
let route = function(statusArg: boolean){
|
||||
if (statusArg === true) {
|
||||
console.log = beautyConsole.log
|
||||
console.error = beautyConsole.error
|
||||
} else {
|
||||
console.log = nativeLog
|
||||
}
|
||||
}
|
||||
|
||||
export let beautyConsole = {
|
||||
log: function(logArg: any) {
|
||||
if (oraActive) {
|
||||
activeOra.pause()
|
||||
nativeLog.apply(nativeLog, arguments)
|
||||
activeOra.start()
|
||||
} else {
|
||||
nativeLog.apply(nativeLog, arguments)
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
if (oraActive) {
|
||||
activeOra.pause()
|
||||
nativeLog.apply(nativeError, arguments)
|
||||
activeOra.start()
|
||||
} else {
|
||||
nativeLog.apply(nativeError, arguments)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
route(true)
|
@ -1,61 +0,0 @@
|
||||
import 'typings-global'
|
||||
import plugins = require('./beautylog.plugins')
|
||||
|
||||
export interface IFigletOptions {
|
||||
font?: string
|
||||
color?: plugins.beautycolor.TColorName
|
||||
cb?
|
||||
}
|
||||
|
||||
let defaultOptions: IFigletOptions = {
|
||||
font: 'Star Wars',
|
||||
color: 'green',
|
||||
cb: function() {}
|
||||
}
|
||||
|
||||
export let figlet = function(textArg: string, optionsArg?){
|
||||
let done = plugins.q.defer()
|
||||
let mergeOptions = plugins.lodash.cloneDeep(defaultOptions)
|
||||
let options = plugins.lodash.assign(mergeOptions,optionsArg)
|
||||
plugins.figlet(
|
||||
textArg,
|
||||
{
|
||||
font: options.font,
|
||||
horizontalLayout: 'default',
|
||||
verticalLayout: 'default'
|
||||
},
|
||||
function(err, data: string) {
|
||||
if (err) {
|
||||
console.log('Something went wrong...')
|
||||
console.dir(err)
|
||||
return
|
||||
}
|
||||
console.log(colorFiglet(data, options.color))
|
||||
options.cb()
|
||||
done.resolve()
|
||||
}
|
||||
)
|
||||
return done.promise
|
||||
}
|
||||
|
||||
export let figletSync = function(textArg: string,optionsArg?: IFigletOptions){
|
||||
let mergeOptions = plugins.lodash.cloneDeep(defaultOptions)
|
||||
let options = plugins.lodash.assign(mergeOptions,optionsArg)
|
||||
let figletString: string = plugins.figlet.textSync(textArg,{
|
||||
font: options.font,
|
||||
horizontalLayout: 'default',
|
||||
verticalLayout: 'default'
|
||||
})
|
||||
console.log(colorFiglet(figletString, options.color))
|
||||
return true
|
||||
}
|
||||
|
||||
let colorFiglet = (figletStringArg, colorArg: plugins.beautycolor.TColorName) => {
|
||||
let figletArray = figletStringArg.split('\n')
|
||||
let figletStringCombined = ''
|
||||
for (let figletRow of figletArray ) {
|
||||
figletRow = plugins.beautycolor.coloredString(figletRow, colorArg)
|
||||
figletStringCombined = figletStringCombined + figletRow + '\n'
|
||||
}
|
||||
return figletStringCombined
|
||||
}
|
@ -1,112 +0,0 @@
|
||||
import * as plugins from './beautylog.plugins'
|
||||
import { remoteLog } from './beautylog.remote'
|
||||
|
||||
/**
|
||||
*
|
||||
* @param logText
|
||||
* @param logType
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export let internalLog = function (logType: string = 'normal', logText: string = 'empty log') {
|
||||
switch (plugins.smartenv.getEnv().runtimeEnv) {
|
||||
case 'node':
|
||||
logNode(logType, logText)
|
||||
remoteLog(logType, logText)
|
||||
break
|
||||
case 'browser':
|
||||
logBrowser(logText, logType)
|
||||
break
|
||||
default:
|
||||
console.log('something is strange about the platform in which you try to use beautylog')
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
let coloredString = plugins.beautycolor.coloredString
|
||||
|
||||
let localBl = {
|
||||
dirPrefix: coloredString(' DIR ', 'white', 'blue') + ' ',
|
||||
errorPrefix: coloredString(' ', 'red', 'red') + coloredString(' ERROR! ', 'red', 'black') + ' ',
|
||||
infoPrefix: coloredString(' ', 'blue', 'blue') + coloredString(' INFO: ', 'blue', 'black') + ' ',
|
||||
logPrefix: coloredString(' ', 'white', 'cyan') + coloredString(' LOG: ', 'cyan', 'black') + ' ',
|
||||
notePrefix: coloredString(' ', 'pink', 'pink') + coloredString(' NOTE -> ', 'pink', 'black') + ' ',
|
||||
okPrefix: coloredString(' ', 'green', 'green') + coloredString(' OK! ', 'green', 'black') + ' ',
|
||||
successPrefix: coloredString(' ', 'green', 'green') + coloredString(' SUCCESS! ', 'green', 'black') + ' ',
|
||||
warnPrefix: coloredString(' ', 'orange', 'orange') + coloredString(' WARN: -> ', 'orange', 'black') + ' '
|
||||
}
|
||||
|
||||
export let logNode = function (logType: string, logText: string) {
|
||||
try {
|
||||
switch (logType) {
|
||||
case 'dir':
|
||||
logText = localBl.dirPrefix + coloredString(logText, 'blue')
|
||||
break
|
||||
case 'error':
|
||||
logText = localBl.errorPrefix + coloredString(logText, 'red')
|
||||
break
|
||||
case 'info':
|
||||
logText = localBl.infoPrefix + coloredString(logText, 'blue')
|
||||
break
|
||||
case 'normal':
|
||||
logText = localBl.logPrefix + coloredString(logText, 'cyan')
|
||||
break
|
||||
case 'note':
|
||||
logText = localBl.notePrefix + coloredString(logText, 'pink')
|
||||
break
|
||||
case 'ok':
|
||||
logText = localBl.okPrefix + coloredString(logText, 'green')
|
||||
break
|
||||
case 'success':
|
||||
logText = localBl.successPrefix + coloredString(logText, 'green')
|
||||
break
|
||||
case 'warn':
|
||||
logText = localBl.warnPrefix + coloredString(logText, 'orange')
|
||||
break
|
||||
case 'log':
|
||||
logText = localBl.logPrefix + coloredString(logText, 'cyan')
|
||||
break
|
||||
default:
|
||||
coloredString(logText, 'blue')
|
||||
console.log(('unknown logType for "' + logText + '"'))
|
||||
break
|
||||
}
|
||||
console.log(logText)
|
||||
return true
|
||||
} catch (error) {
|
||||
console.log(localBl.errorPrefix
|
||||
+ 'You seem to have tried logging something strange' + error)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
let logBrowser = function (logText, logType) {
|
||||
switch (logType) {
|
||||
case 'dir':
|
||||
logText = localBl.dirPrefix + coloredString(logText, 'blue')
|
||||
break
|
||||
case 'error':
|
||||
logText = localBl.errorPrefix + logText.red.bold
|
||||
break
|
||||
case 'info':
|
||||
console.log('%c Info: %c ' + logText, 'background:#EC407A;color:#ffffff;', 'color:#EC407A;')
|
||||
break
|
||||
case 'normal':
|
||||
logText = localBl.logPrefix + logText.cyan.bold
|
||||
break
|
||||
case 'ok':
|
||||
console.log('%c OK: %c ' + logText, 'background:#000000;color:#8BC34A;', 'color:#000000;')
|
||||
break
|
||||
case 'success':
|
||||
console.log('%c Success: %c ' + logText, 'background:#8BC34A;color:#ffffff;', 'color:#8BC34A;')
|
||||
break
|
||||
case 'warn':
|
||||
console.log('%c Warn: %c ' + logText, 'background:#000000;color:#FB8C00;', 'color:#000000;')
|
||||
break
|
||||
case 'log':
|
||||
console.log('%c Log: %c ' + logText, 'background:#42A5F5;color:#ffffff', 'color:#42A5F5;')
|
||||
break
|
||||
default:
|
||||
console.log('unknown logType for "' + logText + '"')
|
||||
break
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
import 'typings-global'
|
||||
|
||||
import {internalLog} from './beautylog.log.helpers'
|
||||
|
||||
/**
|
||||
* logs an info to console
|
||||
* @param logText
|
||||
* @returns {boolean}
|
||||
*/
|
||||
|
||||
export let log = (logText) => {
|
||||
return internalLog('log',logText)
|
||||
}
|
||||
|
||||
export let info = (logText) => {
|
||||
return internalLog('info',logText)
|
||||
}
|
||||
|
||||
/**
|
||||
* logs an 'OK!' message to console
|
||||
* @param logText
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export let ok = (logText) => {
|
||||
return internalLog('ok',logText)
|
||||
}
|
||||
|
||||
/**
|
||||
* logs a success to console
|
||||
* @param logText string to log as error
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export let success = (logText) => {
|
||||
return internalLog('success',logText)
|
||||
}
|
||||
|
||||
/**
|
||||
* logs a 'warn:' message to console
|
||||
* @param logText string to log as error
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export let warn = (logText) => {
|
||||
return internalLog('warn',logText)
|
||||
}
|
||||
|
||||
/**
|
||||
* logs an error to console
|
||||
* @param logText
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export let error = (logText) => {
|
||||
return internalLog('error',logText)
|
||||
}
|
||||
|
||||
/**
|
||||
* logs an directory to console
|
||||
* @param logText
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export let dir = (logText) => {
|
||||
return internalLog('dir',logText)
|
||||
}
|
||||
|
||||
/**
|
||||
* note
|
||||
*/
|
||||
export let note = (logText) => {
|
||||
return internalLog('note', logText)
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new empty line
|
||||
* @param linesArg
|
||||
* @returns void
|
||||
*/
|
||||
export let newLine = (linesArg: number = 1) => {
|
||||
for (let i = 0; i < linesArg; i++) {
|
||||
console.log('\n')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* logs a reduced log that only logs changes of consequential log messages
|
||||
*/
|
||||
export let logReduced = (logTextArg: string,repeatEveryTimesArg: number = 0) => {
|
||||
if (logTextArg === previousMessage && (repeatEveryTimesArg === 0 || sameMessageCounter !== repeatEveryTimesArg)) {
|
||||
sameMessageCounter++
|
||||
} else {
|
||||
sameMessageCounter = 0
|
||||
previousMessage = logTextArg
|
||||
log(logTextArg)
|
||||
}
|
||||
}
|
||||
let previousMessage: string = ''
|
||||
let sameMessageCounter: number = 0
|
@ -1,17 +0,0 @@
|
||||
import 'typings-global'
|
||||
|
||||
import * as beautycolor from 'beautycolor'
|
||||
import * as lodash from 'lodash'
|
||||
import * as smartenv from 'smartenv'
|
||||
import * as q from 'smartq'
|
||||
let figlet = require('figlet')
|
||||
let ora = require('ora')
|
||||
|
||||
export {
|
||||
beautycolor,
|
||||
lodash,
|
||||
smartenv,
|
||||
q,
|
||||
figlet,
|
||||
ora
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
import {remoteArray} from './beautylog.remote'
|
||||
|
||||
/**
|
||||
* registers a remote
|
||||
*/
|
||||
export let registerRemote = (remoteArg: any) => {
|
||||
remoteArray.push(remoteArg)
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
import * as plugins from './beautylog.plugins'
|
||||
|
||||
export interface ILogMethod {
|
||||
(logType: string, logMessage: string): void
|
||||
}
|
||||
|
||||
export interface IBeautyRemote {
|
||||
log: ILogMethod
|
||||
}
|
||||
|
||||
export let remoteArray: IBeautyRemote[] = []
|
||||
|
||||
export let remoteLog = (logType: string, logMessage: string) => {
|
||||
for (let beautyremote of remoteArray) {
|
||||
beautyremote.log(logType, logMessage)
|
||||
}
|
||||
}
|
135
ts/classes.destinationlocal.ts
Normal file
135
ts/classes.destinationlocal.ts
Normal file
@ -0,0 +1,135 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import type { ILogDestination, ILogPackage, TLogLevel } from '@push.rocks/smartlog-interfaces';
|
||||
|
||||
// other beautylog classes
|
||||
import { type TColorName } from '@push.rocks/consolecolor';
|
||||
|
||||
export class DestinationLocal implements ILogDestination {
|
||||
/**
|
||||
* handles a log according to the smartlog standard
|
||||
* @param logPackage
|
||||
*/
|
||||
public async handleLog(logPackage: ILogPackage) {
|
||||
this.logToConsole(logPackage);
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a new empty line
|
||||
* @param linesArg
|
||||
* @returns void
|
||||
*/
|
||||
public newLine(linesArg: number = 1) {
|
||||
for (let i = 0; i < linesArg; i++) {
|
||||
console.log('\n');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* logs a reduced log that only logs changes of consequential log messages
|
||||
*/
|
||||
public logReduced(logTextArg: string, repeatEveryTimesArg: number = 0) {
|
||||
if (
|
||||
logTextArg === this.previousMessage &&
|
||||
(repeatEveryTimesArg === 0 || this.sameMessageCounter !== repeatEveryTimesArg)
|
||||
) {
|
||||
this.sameMessageCounter++;
|
||||
} else {
|
||||
this.sameMessageCounter = 0;
|
||||
this.previousMessage = logTextArg;
|
||||
this.logToConsole({
|
||||
timestamp: Date.now(),
|
||||
type: 'log',
|
||||
level: 'info',
|
||||
context: {
|
||||
company: 'undefined',
|
||||
companyunit: 'undefined',
|
||||
containerName: 'undefined',
|
||||
environment: 'test',
|
||||
runtime: 'node',
|
||||
zone: 'undefined',
|
||||
},
|
||||
message: logTextArg,
|
||||
correlation: {
|
||||
id: 'none',
|
||||
type: 'none',
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
private previousMessage: string = '';
|
||||
private sameMessageCounter: number = 0;
|
||||
|
||||
// default logging
|
||||
private logToConsole(logPackageArg: ILogPackage) {
|
||||
let logString: string;
|
||||
try {
|
||||
logString =
|
||||
this.localBl[logPackageArg.level].prefix +
|
||||
plugins.consolecolor.coloredString(
|
||||
logPackageArg.message,
|
||||
this.localBl[logPackageArg.level].textColor
|
||||
);
|
||||
console.log(logString);
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.log(
|
||||
this.localBl.errorPrefix + 'You seem to have tried logging something strange' + error
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private localBl: {
|
||||
[key: string]: {
|
||||
prefix: string;
|
||||
textColor: TColorName;
|
||||
};
|
||||
} = {
|
||||
silly: {
|
||||
prefix: plugins.consolecolor.coloredString(' silly ', 'white', 'blue') + ' ',
|
||||
textColor: 'blue',
|
||||
},
|
||||
error: {
|
||||
prefix:
|
||||
plugins.consolecolor.coloredString(' ', 'red', 'red') +
|
||||
plugins.consolecolor.coloredString(' ERROR! ', 'red', 'black') +
|
||||
' ',
|
||||
textColor: 'red',
|
||||
},
|
||||
info: {
|
||||
prefix:
|
||||
plugins.consolecolor.coloredString(' ', 'blue', 'blue') +
|
||||
plugins.consolecolor.coloredString(' info: ', 'blue', 'black') +
|
||||
' ',
|
||||
textColor: 'white',
|
||||
},
|
||||
note: {
|
||||
prefix:
|
||||
plugins.consolecolor.coloredString(' ', 'pink', 'pink') +
|
||||
plugins.consolecolor.coloredString(' note -> ', 'pink', 'black') +
|
||||
' ',
|
||||
textColor: 'pink',
|
||||
},
|
||||
ok: {
|
||||
prefix:
|
||||
plugins.consolecolor.coloredString(' ', 'green', 'green') +
|
||||
plugins.consolecolor.coloredString(' ok ', 'green', 'black') +
|
||||
' ',
|
||||
textColor: 'green',
|
||||
},
|
||||
success: {
|
||||
prefix:
|
||||
plugins.consolecolor.coloredString(' ', 'green', 'green') +
|
||||
plugins.consolecolor.coloredString(' SUCCESS! ', 'green', 'black') +
|
||||
' ',
|
||||
textColor: 'green',
|
||||
},
|
||||
warn: {
|
||||
prefix:
|
||||
plugins.consolecolor.coloredString(' ', 'orange', 'orange') +
|
||||
plugins.consolecolor.coloredString(' WARN -> ', 'orange', 'black') +
|
||||
' ',
|
||||
textColor: 'orange',
|
||||
},
|
||||
};
|
||||
}
|
11
ts/index.ts
11
ts/index.ts
@ -1,11 +1,2 @@
|
||||
import 'typings-global'
|
||||
import './beautylog.console'
|
||||
|
||||
import * as plugins from './beautylog.plugins'
|
||||
// export classes
|
||||
export { ora } from './beautylog.classes.ora'
|
||||
|
||||
// export methods
|
||||
export { dir, error, info, log, logReduced, note, ok, success, warn, newLine } from './beautylog.log'
|
||||
export { figlet, figletSync } from './beautylog.figlet'
|
||||
export { registerRemote } from './beautylog.register'
|
||||
export { DestinationLocal } from './classes.destinationlocal.js';
|
||||
|
5
ts/plugins.ts
Normal file
5
ts/plugins.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import * as consolecolor from '@push.rocks/consolecolor';
|
||||
import * as smartlogInterfaces from '@push.rocks/smartlog-interfaces';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
|
||||
export { consolecolor, smartlogInterfaces, smartpromise };
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user