Compare commits
82 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 | |||
9d386f7c45 | |||
be3bdde24b | |||
271fd4817e | |||
5288a1583d | |||
21979e431d | |||
fdd3498d78 | |||
f93317bd02 | |||
0e0a8dfebd | |||
06c29f97b1 | |||
8e3dc5b003 | |||
07d19416fd | |||
2c011ae852 | |||
b6c0b17ef8 | |||
f72f5a0765 | |||
b6d6766c91 | |||
7b238535c8 | |||
0b94ab3a04 | |||
224ed76018 | |||
382d00cfa6 | |||
f6b9e7a4db | |||
ffe65ff1bc | |||
6eb2f8d623 | |||
0244885479 | |||
615e1fe077 | |||
62f2f23522 | |||
56a7ab7858 | |||
a343f715aa | |||
7e4012ccf7 | |||
a42dd0ed45 | |||
b68eba502f | |||
9f20a533be |
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
|
121
.gitlab-ci.yml
121
.gitlab-ci.yml
@ -1,49 +1,128 @@
|
||||
image: hosttoday/ht-docker-node:npmts
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- page
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
testLEGACY:
|
||||
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 command npm config set registry https://registry.npmjs.org
|
||||
- npmci command pnpm audit --audit-level=high --prod
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
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 legacy
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testLTS:
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
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
|
||||
|
||||
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: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmpage
|
||||
stage: page
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci test stable
|
||||
- npmci command npmpage --host gitlab
|
||||
- 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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
69
README.md
69
README.md
@ -1,69 +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/docs)
|
||||
[](https://pushrocks.gitlab.io/beautylog/api)
|
||||
|
||||
## Status for master
|
||||
[](https://gitlab.com/pushrocks/beautylog/commits/master)
|
||||
[](https://gitlab.com/pushrocks/beautylog/commits/master)
|
||||
[](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/)
|
||||
|
||||
## Usage
|
||||
|
||||
```typescript
|
||||
import * as beautylog from 'beautylog'
|
||||
|
||||
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
|
||||
```
|
||||
The plugin produces beautiful output like this:
|
||||

|
||||
|
||||
### 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.
|
||||
|
||||
```typescript
|
||||
let myOra = new beautylog.Ora('my awesome text', 'blue')
|
||||
myOra.start()
|
||||
beautylog.info('some persistent text') //does not disturb myOra
|
||||
console.log('something') // even this works because console.log is monkeypatched by beautylog
|
||||
myOra.text('some updated text')
|
||||
myOra.stop()
|
||||
```
|
||||
|
||||
## Centralized remote logging
|
||||
Beautylog makes it easy to have all your node applications log to a remote location.
|
||||
|
||||
Currently supported remote providers:
|
||||
|
||||
* loggly.com
|
||||
|
||||
```typescript
|
||||
beautylog.remote.loggly({
|
||||
token: 'loggly-token',
|
||||
subdomain: 'loggly-subdomain',
|
||||
appName: 'some App Name',
|
||||
serverName: 'some Server Name'
|
||||
})
|
||||
```
|
||||
|
||||
> Note: since 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 loggly as well.
|
||||
|
||||
For more information read the docs!
|
||||
|
||||
[](https://push.rocks)
|
15
dist/beautylog.classes.ora.d.ts
vendored
15
dist/beautylog.classes.ora.d.ts
vendored
@ -1,15 +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;
|
||||
}
|
53
dist/beautylog.classes.ora.js
vendored
53
dist/beautylog.classes.ora.js
vendored
@ -1,53 +0,0 @@
|
||||
"use strict";
|
||||
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();
|
||||
}
|
||||
}
|
||||
exports.Ora = Ora;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLmNsYXNzZXMub3JhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvYmVhdXR5bG9nLmNsYXNzZXMub3JhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ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BQyxJQUFJLEVBQUUsQ0FBQTtRQUN0QixJQUFJLENBQUMsVUFBVSxDQUFDLEtBQUssRUFBRSxDQUFBO1FBQ3ZCLGlCQUFTLEdBQUcsU0FBUyxDQUFBO1FBQ3JCLGlCQUFTLEdBQUcsS0FBSyxDQUFBO0lBQ3JCLENBQUM7SUFDRCxLQUFLLENBQUMsT0FBTztRQUNULElBQUksQ0FBQyxHQUFHLEVBQUUsQ0FBQTtRQUNWLCtCQUFPLENBQUMsSUFBSSxFQUFDLE9BQU8sQ0FBQyxDQUFBO0lBQ3pCLENBQUM7SUFDRCxRQUFRLENBQUMsT0FBTztRQUNaLElBQUksQ0FBQyxHQUFHLEVBQUUsQ0FBQTtRQUNWLCtCQUFPLENBQUMsT0FBTyxFQUFDLE9BQU8sQ0FBQyxDQUFBO0lBQzVCLENBQUM7SUFDRCxLQUFLO1FBQ0QsSUFBSSxDQUFDLFVBQVUsQ0FBQyxJQUFJLEVBQUUsQ0FBQTtJQUMxQixDQUFDO0lBQ0QsSUFBSTtRQUNBLElBQUksQ0FBQyxHQUFHLEVBQUUsQ0FBQTtJQUNkLENBQUM7Q0FDSjtBQTVDRCxrQkE0Q0MifQ==
|
5
dist/beautylog.console.d.ts
vendored
5
dist/beautylog.console.d.ts
vendored
@ -1,5 +0,0 @@
|
||||
import 'typings-global';
|
||||
export declare let beautyConsole: {
|
||||
log: (logArg: any) => void;
|
||||
error: () => void;
|
||||
};
|
41
dist/beautylog.console.js
vendored
41
dist/beautylog.console.js
vendored
@ -1,41 +0,0 @@
|
||||
"use strict";
|
||||
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLmNvbnNvbGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9iZWF1dHlsb2cuY29uc29sZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBRXZCLG1FQUE4RDtBQUM5RCxJQUFJLFNBQVMsR0FBRyxPQUFPLENBQUMsR0FBRyxDQUFBO0FBQzNCLElBQUksV0FBVyxHQUFHLE9BQU8sQ0FBQyxLQUFLLENBQUE7QUFFL0I7O0dBRUc7QUFDSCxJQUFJLEtBQUssR0FBRyxVQUFTLFNBQWtCO0lBQ25DLEVBQUUsQ0FBQyxDQUFDLFNBQVMsS0FBSyxJQUFJLENBQUMsQ0FBQyxDQUFDO1FBQ3JCLE9BQU8sQ0FBQyxHQUFHLEdBQUcscUJBQWEsQ0FBQyxHQUFHLENBQUE7UUFDL0IsT0FBTyxDQUFDLEtBQUssR0FBRyxxQkFBYSxDQUFDLEtBQUssQ0FBQTtJQUN2QyxDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDSixPQUFPLENBQUMsR0FBRyxHQUFHLFNBQVMsQ0FBQTtJQUMzQixDQUFDO0FBQ0wsQ0FBQyxDQUFBO0FBRVUsUUFBQSxhQUFhLEdBQUc7SUFDdkIsR0FBRyxFQUFFLFVBQVMsTUFBVztRQUNyQixFQUFFLENBQUMsQ0FBQyxpQ0FBUyxDQUFDLENBQUMsQ0FBQztZQUNaLGlDQUFTLENBQUMsS0FBSyxFQUFFLENBQUE7WUFDakIsU0FBUyxDQUFDLEtBQUssQ0FBQyxTQUFTLEVBQUUsU0FBUyxDQUFDLENBQUE7WUFDckMsaUNBQVMsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtRQUNyQixDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDSixTQUFTLENBQUMsS0FBSyxDQUFDLFNBQVMsRUFBRSxTQUFTLENBQUMsQ0FBQTtRQUN6QyxDQUFDO0lBQ0wsQ0FBQztJQUNELEtBQUssRUFBRTtRQUNILEVBQUUsQ0FBQyxDQUFDLGlDQUFTLENBQUMsQ0FBQyxDQUFDO1lBQ1osaUNBQVMsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtZQUNqQixTQUFTLENBQUMsS0FBSyxDQUFDLFdBQVcsRUFBRSxTQUFTLENBQUMsQ0FBQTtZQUN2QyxpQ0FBUyxDQUFDLEtBQUssRUFBRSxDQUFBO1FBQ3JCLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNKLFNBQVMsQ0FBQyxLQUFLLENBQUMsV0FBVyxFQUFFLFNBQVMsQ0FBQyxDQUFBO1FBQzNDLENBQUM7SUFDTCxDQUFDO0NBQ0osQ0FBQTtBQUVELEtBQUssQ0FBQyxJQUFJLENBQUMsQ0FBQSJ9
|
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;
|
49
dist/beautylog.figlet.js
vendored
49
dist/beautylog.figlet.js
vendored
@ -1,49 +0,0 @@
|
||||
"use strict";
|
||||
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;
|
||||
};
|
||||
//# sour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FvQixHQUFHLEVBQUUsQ0FBQTtJQUM3QixHQUFHLENBQUMsQ0FBQyxJQUFJLFNBQVMsSUFBSSxXQUFZLENBQUMsQ0FBQyxDQUFDO1FBQ2pDLFNBQVMsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLGFBQWEsQ0FBQyxTQUFTLEVBQUUsUUFBUSxDQUFDLENBQUE7UUFDbEUsb0JBQW9CLEdBQUcsb0JBQW9CLEdBQUcsU0FBUyxHQUFHLElBQUksQ0FBQTtJQUNsRSxDQUFDO0lBQ0QsTUFBTSxDQUFDLG9CQUFvQixDQUFBO0FBQy9CLENBQUMsQ0FBQSJ9
|
48
dist/beautylog.log.d.ts
vendored
48
dist/beautylog.log.d.ts
vendored
@ -1,48 +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;
|
||||
/**
|
||||
* 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;
|
107
dist/beautylog.log.helpers.js
vendored
107
dist/beautylog.log.helpers.js
vendored
File diff suppressed because one or more lines are too long
80
dist/beautylog.log.js
vendored
80
dist/beautylog.log.js
vendored
@ -1,80 +0,0 @@
|
||||
"use strict";
|
||||
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);
|
||||
};
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
};
|
||||
let previousMessage = '';
|
||||
let sameMessageCounter = 0;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLmxvZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2JlYXV0eWxvZy5sb2cudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUV2QixtRUFBbUQ7QUFFbkQ7Ozs7R0FJRztBQUVRLFFBQUEsR0FBRyxHQUFHLENBQUMsT0FBTztJQUNyQixNQUFNLENBQUMsbUNBQVcsQ0FBQyxLQUFLLEVBQUMsT0FBTyxDQUFDLENBQUE7QUFDckMsQ0FBQyxDQUFBO0FBRVUsUUFBQSxJQUFJLEdBQUcsQ0FBQyxPQUFPO0lBQ3RCLE1BQU0sQ0FBQyxtQ0FBVyxDQUFDLE1BQU0sRUFBQyxPQUFPLENBQUMsQ0FBQTtBQUN0QyxDQUFDLENBQUE7QUFFR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7O0dBRUc7QUFDUSxRQUFBLFVBQVUsR0FBRyxDQUFDLFVBQWtCLEVBQUMsc0JBQThCLENBQUM7SUFDdkUsRUFBRSxDQUFDLENBQUMsVUFBVSxLQUFLLGVBQWUsSUFBSSxDQUFDLG1CQUFtQixLQUFLLENBQUMsSUFBSSxrQkFBa0IsS0FBSyxtQkFBbUIsQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUM5RyxrQkFBa0IsRUFBRSxDQUFBO0lBQ3hCLENBQUM7SUFBQyxJQUFJLENBQUMsQ0FBQztRQUNKLGtCQUFrQixHQUFHLENBQUMsQ0FBQTtRQUN0QixlQUFlLEdBQUcsVUFBVSxDQUFBO1FBQzVCLFdBQUcsQ0FBQyxVQUFVLENBQUMsQ0FBQTtJQUNuQixDQUFDO0FBQ0wsQ0FBQyxDQUFBO0FBQ0QsSUFBSSxlQUFlLEdBQVcsRUFBRSxDQUFBO0FBQ2hDLElBQUksa0JBQWtCLEdBQVcsQ0FBQyxDQUFBIn0=
|
9
dist/beautylog.plugins.d.ts
vendored
9
dist/beautylog.plugins.d.ts
vendored
@ -1,9 +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;
|
||||
import * as loggly from 'loggly';
|
||||
declare let ora: any;
|
||||
export { beautycolor, lodash, smartenv, q, figlet, loggly, ora };
|
17
dist/beautylog.plugins.js
vendored
17
dist/beautylog.plugins.js
vendored
@ -1,17 +0,0 @@
|
||||
"use strict";
|
||||
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;
|
||||
const loggly = require("loggly");
|
||||
exports.loggly = loggly;
|
||||
let ora = require('ora');
|
||||
exports.ora = ora;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9iZWF1dHlsb2cucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBRXZCLDJDQUEwQztBQVN0QyxrQ0FBVztBQVJmLGlDQUFnQztBQVM1Qix3QkFBTTtBQVJWLHFDQUFvQztBQVNoQyw0QkFBUTtBQVJaLDRCQUEyQjtBQVN2QixjQUFDO0FBUkwsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFBO0FBUzFCLHdCQUFNO0FBUlYsaUNBQWdDO0FBUzVCLHdCQUFNO0FBUlYsSUFBSSxHQUFHLEdBQUcsT0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFBO0FBU3BCLGtCQUFHIn0=
|
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: any;
|
2
dist/beautylog.register.js
vendored
2
dist/beautylog.register.js
vendored
@ -1,2 +0,0 @@
|
||||
"use strict";
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLnJlZ2lzdGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvYmVhdXR5bG9nLnJlZ2lzdGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
9
dist/beautylog.remote.d.ts
vendored
9
dist/beautylog.remote.d.ts
vendored
@ -1,9 +0,0 @@
|
||||
export declare let remoteLog: (logType: string, logMessage: string) => void;
|
||||
export declare let remote: {
|
||||
loggly: (optionsArg: {
|
||||
token: string;
|
||||
subdomain: string;
|
||||
appName: string;
|
||||
serverName: string;
|
||||
}) => void;
|
||||
};
|
32
dist/beautylog.remote.js
vendored
32
dist/beautylog.remote.js
vendored
@ -1,32 +0,0 @@
|
||||
"use strict";
|
||||
const plugins = require("./beautylog.plugins");
|
||||
let client;
|
||||
let clientData = {
|
||||
serverName: 'myServer',
|
||||
applicationName: 'myApp',
|
||||
message: 'undefined',
|
||||
messageType: 'undefined'
|
||||
};
|
||||
exports.remoteLog = (logType, logMessage) => {
|
||||
clientData.messageType = logType;
|
||||
clientData.message = logMessage;
|
||||
if (client) {
|
||||
client.log(clientData);
|
||||
}
|
||||
;
|
||||
};
|
||||
// Service implementations
|
||||
let loggly = (optionsArg) => {
|
||||
client = plugins.loggly.createClient({
|
||||
token: optionsArg.token,
|
||||
subdomain: optionsArg.subdomain,
|
||||
tags: [],
|
||||
json: true
|
||||
});
|
||||
clientData.applicationName = optionsArg.appName;
|
||||
clientData.serverName = optionsArg.serverName;
|
||||
};
|
||||
exports.remote = {
|
||||
loggly: loggly
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLnJlbW90ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2JlYXV0eWxvZy5yZW1vdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLCtDQUE4QztBQUU5QyxJQUFJLE1BQU0sQ0FBQTtBQUNWLElBQUksVUFBVSxHQUFHO0lBQ2IsVUFBVSxFQUFFLFVBQVU7SUFDdEIsZUFBZSxFQUFFLE9BQU87SUFDeEIsT0FBTyxFQUFFLFdBQVc7SUFDcEIsV0FBVyxFQUFFLFdBQVc7Q0FDM0IsQ0FBQTtBQUNVLFFBQUEsU0FBUyxHQUFHLENBQUMsT0FBZSxFQUFFLFVBQWtCO0lBQ3ZELFVBQVUsQ0FBQyxXQUFXLEdBQUcsT0FBTyxDQUFBO0lBQ2hDLFVBQVUsQ0FBQyxPQUFPLEdBQUcsVUFBVSxDQUFBO0lBQy9CLEVBQUUsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUM7UUFDVCxNQUFNLENBQUMsR0FBRyxDQUFDLFVBQVUsQ0FBQyxDQUFBO0lBQzFCLENBQUM7SUFBQSxDQUFDO0FBQ04sQ0FBQyxDQUFBO0FBRUQsMEJBQTBCO0FBRTFCLElBQUksTUFBTSxHQUFHLENBQUMsVUFLYjtJQUNHLE1BQU0sR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLFlBQVksQ0FBQztRQUNqQyxLQUFLLEVBQUUsVUFBVSxDQUFDLEtBQUs7UUFDdkIsU0FBUyxFQUFFLFVBQVUsQ0FBQyxTQUFTO1FBQy9CLElBQUksRUFBRSxFQUFFO1FBQ1IsSUFBSSxFQUFFLElBQUk7S0FDYixDQUFDLENBQUE7SUFDRixVQUFVLENBQUMsZUFBZSxHQUFHLFVBQVUsQ0FBQyxPQUFPLENBQUE7SUFDL0MsVUFBVSxDQUFDLFVBQVUsR0FBRyxVQUFVLENBQUMsVUFBVSxDQUFBO0FBQ2pELENBQUMsQ0FBQTtBQUVVLFFBQUEsTUFBTSxHQUFHO0lBQ2hCLE1BQU0sRUFBRSxNQUFNO0NBQ2pCLENBQUEifQ==
|
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, ok, success, warn, newLine } from './beautylog.log';
|
||||
export { figlet, figletSync } from './beautylog.figlet';
|
||||
export { remote } from './beautylog.remote';
|
23
dist/index.js
vendored
23
dist/index.js
vendored
@ -1,23 +0,0 @@
|
||||
"use strict";
|
||||
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.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_remote_1 = require("./beautylog.remote");
|
||||
exports.remote = beautylog_remote_1.remote;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLCtCQUE0QjtBQUc1QixpQkFBaUI7QUFDakIsaUVBQTJDO0FBQW5DLHNDQUFBLEdBQUcsQ0FBQTtBQUVYLGlCQUFpQjtBQUNqQixpREFBcUY7QUFBN0UsOEJBQUEsR0FBRyxDQUFBO0FBQUMsZ0NBQUEsS0FBSyxDQUFBO0FBQUMsK0JBQUEsSUFBSSxDQUFBO0FBQUMsOEJBQUEsR0FBRyxDQUFBO0FBQUMscUNBQUEsVUFBVSxDQUFBO0FBQUMsNkJBQUEsRUFBRSxDQUFBO0FBQUMsa0NBQUEsT0FBTyxDQUFBO0FBQUMsK0JBQUEsSUFBSSxDQUFBO0FBQUMsa0NBQUEsT0FBTyxDQUFBO0FBQzdELHVEQUFvRDtBQUE1QyxvQ0FBQSxNQUFNLENBQUE7QUFBQyx3Q0FBQSxVQUFVLENBQUE7QUFDekIsdURBQXlDO0FBQWpDLG9DQUFBLE1BQU0sQ0FBQSJ9
|
@ -1,15 +0,0 @@
|
||||
{
|
||||
"structure": {
|
||||
"readme": "index.md"
|
||||
},
|
||||
"plugins": [
|
||||
"tonic",
|
||||
"edit-link"
|
||||
],
|
||||
"pluginsConfig": {
|
||||
"edit-link": {
|
||||
"base": "https://gitlab.com/pushrocks/beautylog/edit/master/docs/",
|
||||
"label": "Edit on GitLab"
|
||||
}
|
||||
}
|
||||
}
|
113
docs/index.md
113
docs/index.md
@ -1,101 +1,74 @@
|
||||
# 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/docs)
|
||||
[](https://pushrocks.gitlab.io/beautylog/api)
|
||||
|
||||
[](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://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)
|
||||
|
||||
## Usage
|
||||
|
||||
```typescript
|
||||
import * as beautylog from "beautylog";
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
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
|
||||
```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
|
||||
```
|
||||
The plugin produces beautiful output like this:
|
||||

|
||||
|
||||
### 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.
|
||||
|
||||
```typescript
|
||||
var myOra = new beautylog.Ora("my awesome text", "blue");
|
||||
myOra.start();
|
||||
beautylog.info("some persistent text") //does not disturb myOra
|
||||
console.log("something") // even this works because console.log is monkeypatched by beautylog
|
||||
myOra.text("some updated text");
|
||||
myOra.stop();
|
||||
```
|
||||
|
||||
### Console Tables
|
||||
beautylog allows displaying data in nice tables for better overview.
|
||||
|
||||
> **Note:** This only works only in nodejs for now.
|
||||
|
||||
There are different types of tables.
|
||||
|
||||
#### Custom
|
||||
|
||||
```javascript
|
||||
var beautylog = require("beautylog");
|
||||
var myTable = beautylog.table.new("custom",["Heading1".blue,"Heading2".blue,"Heading3".blue]); // type "custom"
|
||||
myTable.push(["check 1","success"]); // adds a row the myTable
|
||||
myTable.push(["check 2","error"]); // adds a row the myTable
|
||||
myTable.push(["check 3","error"]); // adds a row the myTable
|
||||
myTable.print(); //prints myTable to the console
|
||||
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();
|
||||
```
|
||||
|
||||
#### Checks
|
||||
|
||||
```javascript
|
||||
var beautylog = require("beautylog");
|
||||
var myTable = beautylog.table.new("checks"); // type checks
|
||||
myTable.push(["check 1","success"]); // adds a row to myTable
|
||||
myTable.push(["check 2","error"]); // adds a row to myTable
|
||||
myTable.push(["check 3","error"]); // adds a row to myTable
|
||||
myTable.print(); //prints myTable to console
|
||||
```
|
||||
|
||||
The table from the code with type "checks" above looks like this:
|
||||

|
||||
|
||||
## Centralized remote logging
|
||||
|
||||
Beautylog makes it easy to have all your node applications log to a remote location.
|
||||
|
||||
Currently supported remote providers:
|
||||
|
||||
* loggly.com
|
||||
|
||||
```typescript
|
||||
beautylog.remote.loggly({
|
||||
token: "loggly-token",
|
||||
subdomain: "loggly-subdomain",
|
||||
appName: "some App Name",
|
||||
serverName: "some Server Name"
|
||||
```javascript
|
||||
import { Loggly } from 'beautyremote';
|
||||
let myLogglyRemote = new Loggly({
|
||||
token: 'my_super_long_token_here',
|
||||
});
|
||||
beautylog.registerRemote(myLogglyRemote);
|
||||
```
|
||||
|
||||
> Note: since 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 loggly as well.
|
||||
> 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.
|
||||
|
||||
For more information read the docs!
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
[](https://push.rocks)
|
||||
> 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)
|
||||
|
@ -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
|
28
npmextra.json
Normal file
28
npmextra.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"npmci": {
|
||||
"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
|
||||
}
|
80
package.json
80
package.json
@ -1,51 +1,59 @@
|
||||
{
|
||||
"name": "beautylog",
|
||||
"version": "6.0.6",
|
||||
"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.x.x",
|
||||
"@types/loggly": "^1.1.30",
|
||||
"beautycolor": "^1.0.5",
|
||||
"figlet": "^1.2.0",
|
||||
"lodash": "^4.17.4",
|
||||
"loggly": "^1.1.1",
|
||||
"ora": "^1.1.0",
|
||||
"smartenv": "^2.0.0",
|
||||
"smartq": "^1.0.4",
|
||||
"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": {
|
||||
"npmts-g": "^6.0.0",
|
||||
"qenv": "^1.1.3",
|
||||
"smartchai": "^1.0.1",
|
||||
"typings-test": "^1.0.3"
|
||||
}
|
||||
}
|
||||
"@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 ***");
|
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@ -1 +0,0 @@
|
||||
import 'typings-test';
|
88
test/test.js
88
test/test.js
@ -1,88 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-test");
|
||||
const beautylog = require("../dist/index");
|
||||
describe('beautylog', function () {
|
||||
describe('.log(message)', function () {
|
||||
it('should print a blue Dir message', function () {
|
||||
beautylog.log('beautylog.log(), with normal logText, without logType');
|
||||
});
|
||||
});
|
||||
describe('.dir(message)', function () {
|
||||
it('should print a blue Dir message', function () {
|
||||
beautylog.dir('beautylog.dir(), with normal logText, without logType');
|
||||
});
|
||||
});
|
||||
describe('.error(message)', function () {
|
||||
it('should print a red error message', function () {
|
||||
beautylog.error('beautylog.error(), with normal logText, without logType');
|
||||
});
|
||||
});
|
||||
describe('.figlet', function () {
|
||||
it('should print nice fonts to console in yellow', function (done) {
|
||||
beautylog.figlet('Async!', { font: 'Star Wars', color: 'orange' }).then(done);
|
||||
});
|
||||
});
|
||||
describe('.figletSync', function () {
|
||||
it('should print nice fonts to console in yellow', function () {
|
||||
beautylog.figletSync('Sync!', { font: 'Star Wars', color: 'blue' });
|
||||
});
|
||||
});
|
||||
describe('.info(message)', function () {
|
||||
it('should display a purple info message', function () {
|
||||
beautylog.info('beautylog.dir(), with normal logText, without logType');
|
||||
});
|
||||
});
|
||||
describe('.logReduced(message)', function () {
|
||||
it('should only log two messages', function () {
|
||||
beautylog.logReduced('Message 1');
|
||||
beautylog.logReduced('Message 1');
|
||||
beautylog.logReduced('Message 1');
|
||||
beautylog.logReduced('Message 1');
|
||||
beautylog.logReduced('Message 2');
|
||||
beautylog.logReduced('Message 2');
|
||||
});
|
||||
});
|
||||
describe('.ok(message)', function () {
|
||||
it('should display a green ok message', function () {
|
||||
beautylog.ok('beautylog.ok(), with normal logText, without logType');
|
||||
});
|
||||
});
|
||||
describe('.newLine(number)', function () {
|
||||
it('create specified amount of new lines', function () {
|
||||
beautylog.newLine(1);
|
||||
});
|
||||
});
|
||||
describe('.ora(text,color)', function () {
|
||||
it('should display, update, and end a message', function (done) {
|
||||
this.timeout(10000);
|
||||
let testOra = new beautylog.Ora('This is a test text', 'green', true);
|
||||
setTimeout(function () {
|
||||
testOra.text('updated text!');
|
||||
beautylog.info('another log message that uses the normal log function');
|
||||
setTimeout(function () {
|
||||
testOra.endOk('Allright, ora works!');
|
||||
done();
|
||||
}, 2000);
|
||||
}, 2000);
|
||||
});
|
||||
it('should display an error message when ended with error', function (done) {
|
||||
this.timeout(10000);
|
||||
let testOra = new beautylog.Ora('This is another test text', 'green');
|
||||
setTimeout(function () {
|
||||
testOra.endError('Allright, ora displays an error!');
|
||||
done();
|
||||
}, 2000);
|
||||
});
|
||||
});
|
||||
describe('.success(message)', function () {
|
||||
it('should display an orange warn message', function () {
|
||||
beautylog.success('beautylog.success(), with normal logText, without logType');
|
||||
});
|
||||
});
|
||||
describe('.warn', function () {
|
||||
it('should display a orange warn message', function () {
|
||||
beautylog.warn('beautylog.warn(), with normal logText, without logType');
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQiwyQ0FBMkM7QUFJM0M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QUE7SUFDTixDQUFDLENBQUMsQ0FBQTtJQUNGLFFBQVEsQ0FBQyxtQkFBbUIsRUFBQztRQUN6QixFQUFFLENBQUMsdUNBQXVDLEVBQUM7WUFDdkMsU0FBUyxDQUFDLE9BQU8sQ0FBQywyREFBMkQsQ0FBQyxDQUFBO1FBQ2xGLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7SUFDRixRQUFRLENBQUMsT0FBTyxFQUFDO1FBQ2IsRUFBRSxDQUFDLHNDQUFzQyxFQUFDO1lBQ3RDLFNBQVMsQ0FBQyxJQUFJLENBQUMsd0RBQXdELENBQUMsQ0FBQTtRQUM1RSxDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ==
|
134
test/test.ts
134
test/test.ts
@ -1,89 +1,49 @@
|
||||
import 'typings-test'
|
||||
import beautylog = require('../dist/index')
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
|
||||
import * as qenv from 'qenv'
|
||||
import * as smartlogDesinationLocal from '../ts/index.js';
|
||||
import type { ILogContext } from '@push.rocks/smartlog-interfaces';
|
||||
|
||||
describe('beautylog',function(){
|
||||
describe('.log(message)',function(){
|
||||
it('should print a blue Dir message',function(){
|
||||
beautylog.log('beautylog.log(), with normal logText, without logType')
|
||||
})
|
||||
})
|
||||
describe('.dir(message)',function(){
|
||||
it('should print a blue Dir message',function(){
|
||||
beautylog.dir('beautylog.dir(), with normal logText, without logType')
|
||||
})
|
||||
})
|
||||
describe('.error(message)',function(){
|
||||
it('should print a red error message',function(){
|
||||
beautylog.error('beautylog.error(), with normal logText, without logType')
|
||||
})
|
||||
})
|
||||
describe('.figlet',function(){
|
||||
it('should print nice fonts to console in yellow',function(done){
|
||||
beautylog.figlet('Async!',{font: 'Star Wars',color: 'orange'}).then(done)
|
||||
})
|
||||
})
|
||||
describe('.figletSync',function(){
|
||||
it('should print nice fonts to console in yellow',function(){
|
||||
beautylog.figletSync('Sync!',{font: 'Star Wars',color: 'blue'})
|
||||
})
|
||||
})
|
||||
describe('.info(message)',function(){
|
||||
it('should display a purple info message',function(){
|
||||
beautylog.info('beautylog.dir(), with normal logText, without logType')
|
||||
})
|
||||
})
|
||||
describe('.logReduced(message)',function(){
|
||||
it('should only log two messages',function(){
|
||||
beautylog.logReduced('Message 1')
|
||||
beautylog.logReduced('Message 1')
|
||||
beautylog.logReduced('Message 1')
|
||||
beautylog.logReduced('Message 1')
|
||||
beautylog.logReduced('Message 2')
|
||||
beautylog.logReduced('Message 2')
|
||||
})
|
||||
})
|
||||
describe('.ok(message)',function(){
|
||||
it('should display a green ok message',function(){
|
||||
beautylog.ok('beautylog.ok(), with normal logText, without logType')
|
||||
})
|
||||
})
|
||||
describe('.newLine(number)',function(){
|
||||
it('create specified amount of new lines',function(){
|
||||
beautylog.newLine(1)
|
||||
})
|
||||
})
|
||||
describe('.ora(text,color)',function(){
|
||||
it('should display, update, and end a message',function(done){
|
||||
this.timeout(10000)
|
||||
let testOra = new beautylog.Ora('This is a test text','green',true)
|
||||
setTimeout(function(){
|
||||
testOra.text('updated text!')
|
||||
beautylog.info('another log message that uses the normal log function')
|
||||
setTimeout(function(){
|
||||
testOra.endOk('Allright, ora works!')
|
||||
done()
|
||||
},2000)
|
||||
},2000)
|
||||
})
|
||||
it('should display an error message when ended with error',function(done){
|
||||
this.timeout(10000)
|
||||
let testOra = new beautylog.Ora('This is another test text','green')
|
||||
setTimeout(function(){
|
||||
testOra.endError('Allright, ora displays an error!')
|
||||
done()
|
||||
},2000)
|
||||
})
|
||||
})
|
||||
describe('.success(message)',function(){
|
||||
it('should display an orange warn message',function(){
|
||||
beautylog.success('beautylog.success(), with normal logText, without logType')
|
||||
})
|
||||
})
|
||||
describe('.warn',function(){
|
||||
it('should display a orange warn message',function(){
|
||||
beautylog.warn('beautylog.warn(), with normal logText, without logType')
|
||||
})
|
||||
})
|
||||
})
|
||||
const testLogContext: ILogContext = {
|
||||
company: 'Lossless GmbH',
|
||||
companyunit: 'Lossless.Cloud',
|
||||
containerName: 'gitlabci',
|
||||
environment: 'staging',
|
||||
runtime: 'node',
|
||||
zone: 'shipzone',
|
||||
};
|
||||
|
||||
let testLocalInstance: smartlogDesinationLocal.DestinationLocal;
|
||||
|
||||
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 () => {
|
||||
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 () => {
|
||||
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 () => {
|
||||
testLocalInstance.newLine(1);
|
||||
});
|
||||
|
||||
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,52 +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()
|
||||
}
|
||||
}
|
@ -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,109 +0,0 @@
|
||||
import * as plugins from './beautylog.plugins'
|
||||
import { beautyConsole } from './beautylog.console'
|
||||
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(' ', 'pink', 'pink') + coloredString(' INFO ', 'pink', 'black') + ' ',
|
||||
logPrefix: coloredString(' ', 'white', 'cyan') + coloredString(' Log: ', 'cyan', '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, 'pink')
|
||||
break
|
||||
case 'normal':
|
||||
logText = localBl.logPrefix + coloredString(logText, 'cyan')
|
||||
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
|
||||
}
|
||||
beautyConsole.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,88 +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)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,19 +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')
|
||||
import * as loggly from 'loggly'
|
||||
let ora = require('ora')
|
||||
|
||||
export {
|
||||
beautycolor,
|
||||
lodash,
|
||||
smartenv,
|
||||
q,
|
||||
figlet,
|
||||
loggly,
|
||||
ora
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* registers a remote
|
||||
*/
|
||||
export let registerRemote
|
@ -1,38 +0,0 @@
|
||||
import * as plugins from './beautylog.plugins'
|
||||
|
||||
let client
|
||||
let clientData = {
|
||||
serverName: 'myServer',
|
||||
applicationName: 'myApp',
|
||||
message: 'undefined',
|
||||
messageType: 'undefined'
|
||||
}
|
||||
export let remoteLog = (logType: string, logMessage: string) => {
|
||||
clientData.messageType = logType
|
||||
clientData.message = logMessage
|
||||
if (client) {
|
||||
client.log(clientData)
|
||||
};
|
||||
}
|
||||
|
||||
// Service implementations
|
||||
|
||||
let loggly = (optionsArg: {
|
||||
token: string,
|
||||
subdomain: string,
|
||||
appName: string,
|
||||
serverName: string
|
||||
}) => {
|
||||
client = plugins.loggly.createClient({
|
||||
token: optionsArg.token,
|
||||
subdomain: optionsArg.subdomain,
|
||||
tags: [],
|
||||
json: true
|
||||
})
|
||||
clientData.applicationName = optionsArg.appName
|
||||
clientData.serverName = optionsArg.serverName
|
||||
}
|
||||
|
||||
export let remote = {
|
||||
loggly: loggly
|
||||
}
|
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,ok,success,warn,newLine} from './beautylog.log'
|
||||
export {figlet,figletSync} from './beautylog.figlet'
|
||||
export {remote} from './beautylog.remote'
|
||||
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