Compare commits
No commits in common. "master" and "v6.0.6" have entirely different histories.
26
.gitignore
vendored
26
.gitignore
vendored
@ -1,20 +1,10 @@
|
||||
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,128 +1,49 @@
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
image: hosttoday/ht-docker-node:npmts
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
- test
|
||||
- release
|
||||
- page
|
||||
|
||||
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:
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
- npmci test legacy
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testBuild:
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
- npmci test lts
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
- npmci 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:
|
||||
stage: metadata
|
||||
image: hosttoday/ht-docker-node:npmpage
|
||||
stage: page
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run buildDocs
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
- npmci test stable
|
||||
- npmci command npmpage --host gitlab
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
||||
- public
|
11
.vscode/launch.json
vendored
11
.vscode/launch.json
vendored
@ -1,11 +0,0 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
26
.vscode/settings.json
vendored
26
.vscode/settings.json
vendored
@ -1,26 +0,0 @@
|
||||
{
|
||||
"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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Lossless GmbH
|
||||
Copyright (c) 2015 Push.Rocks
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
69
README.md
Normal file
69
README.md
Normal file
@ -0,0 +1,69 @@
|
||||
# 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
Normal file
15
dist/beautylog.classes.ora.d.ts
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
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
Normal file
53
dist/beautylog.classes.ora.js
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
"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();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SUFBSSxDQUFDLFVBQVUsQ0FBQyxLQUFLLEdBQUcsUUFBUSxDQUFBO1FBQUMsQ0FBQztRQUNsRCxpQkFBUyxHQUFHLElBQUksQ0FBQTtRQUNoQixpQkFBUyxHQUFHLElBQUksQ0FBQTtRQUNoQixJQUFJLENBQUMsVUFBVSxDQUFDLEtBQUssRUFBRSxDQUFBO0lBQzNCLENBQUM7SUFDRCxHQUFHO1FBQ0MsSUFBSSxDQUFDLFVBQVUsQ0FBQyxJQUFJLEVBQUUsQ0FBQTtRQUN0QixJQUFJLENBQUMsVUFBVSxDQUFDLEtBQUssRUFBRSxDQUFBO1FBQ3ZCLGlCQUFTLEdBQUcsU0FBUyxDQUFBO1FBQ3JCLGlCQUFTLEdBQUcsS0FBSyxDQUFBO0lBQ3JCLENBQUM7SUFDRCxLQUFLLENBQUMsT0FBTztRQUNULElBQUksQ0FBQyxHQUFHLEVBQUUsQ0FBQTtRQUNWLCtCQUFPLENBQUMsSUFBSSxFQUFDLE9BQU8sQ0FBQyxDQUFBO0lBQ3pCLENBQUM7SUFDRCxRQUFRLENBQUMsT0FBTztRQUNaLElBQUksQ0FBQyxHQUFHLEVBQUUsQ0FBQTtRQUNWLCtCQUFPLENBQUMsT0FBTyxFQUFDLE9BQU8sQ0FBQyxDQUFBO0lBQzVCLENBQUM7SUFDRCxLQUFLO1FBQ0QsSUFBSSxDQUFDLFVBQVUsQ0FBQyxJQUFJLEVBQUUsQ0FBQTtJQUMxQixDQUFDO0lBQ0QsSUFBSTtRQUNBLElBQUksQ0FBQyxHQUFHLEVBQUUsQ0FBQTtJQUNkLENBQUM7Q0FDSjtBQTVDRCxrQkE0Q0MifQ==
|
5
dist/beautylog.console.d.ts
vendored
Normal file
5
dist/beautylog.console.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import 'typings-global';
|
||||
export declare let beautyConsole: {
|
||||
log: (logArg: any) => void;
|
||||
error: () => void;
|
||||
};
|
41
dist/beautylog.console.js
vendored
Normal file
41
dist/beautylog.console.js
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
"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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLmNvbnNvbGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9iZWF1dHlsb2cuY29uc29sZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBRXZCLG1FQUE4RDtBQUM5RCxJQUFJLFNBQVMsR0FBRyxPQUFPLENBQUMsR0FBRyxDQUFBO0FBQzNCLElBQUksV0FBVyxHQUFHLE9BQU8sQ0FBQyxLQUFLLENBQUE7QUFFL0I7O0dBRUc7QUFDSCxJQUF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FBQyxLQUFLLENBQUMsV0FBVyxFQUFFLFNBQVMsQ0FBQyxDQUFBO1FBQzNDLENBQUM7SUFDTCxDQUFDO0NBQ0osQ0FBQTtBQUVELEtBQUssQ0FBQyxJQUFJLENBQUMsQ0FBQSJ9
|
9
dist/beautylog.figlet.d.ts
vendored
Normal file
9
dist/beautylog.figlet.d.ts
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
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
Normal file
49
dist/beautylog.figlet.js
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
"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;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLmZpZ2xldC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2JlYXV0eWxvZy5maWdsZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2QiwrQ0FBK0M7QUFRL0MsSUFBSSxjQUFjLEdBQW1CO0lBQ2pDLElBQUksRUFBRSxXQUFXO0lBQ2pCLEtBQUssRUFBRSxPQUFPO0lBQ2QsRUFBRSxFQUFFLGNBQVksQ0FBQztDQUNwQixDQUFBO0FBRVUsUUFBQSxNQUFNLEdBQUcsVUFBUyxPQUFlLEVBQUUsVUFBVztJQUNyRCxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFBO0lBQzVCLElBQUksWUFBWSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLGNBQWMsQ0FBQyxDQUFBO0lBQzNELElBQUksT0FBTyxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLFlBQVksRUFBQyxVQUFVLENBQUMsQ0FBQTtJQUM1RCxPQUFPLENBQUMsTUFBTSxDQUNWLE9BQU8sRUFDUDtRQUNJLElBQUksRUFBRSxPQUFPLENBQUMsSUFBSTtRQUN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FBQyxHQUFHLENBQUMsV0FBVyxDQUFDLFlBQVksRUFBRSxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQTtJQUNyRCxNQUFNLENBQUMsSUFBSSxDQUFBO0FBQ2YsQ0FBQyxDQUFBO0FBRUQsSUFBSSxXQUFXLEdBQUcsQ0FBQyxlQUFlLEVBQUUsUUFBd0M7SUFDeEUsSUFBSSxXQUFXLEdBQUcsZUFBZSxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsQ0FBQTtJQUM3QyxJQUFJLG9CQUFvQixHQUFHLEVBQUUsQ0FBQTtJQUM3QixHQUFHLENBQUMsQ0FBQyxJQUFJLFNBQVMsSUFBSSxXQUFZLENBQUMsQ0FBQyxDQUFDO1FBQ2pDLFNBQVMsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLGFBQWEsQ0FBQyxTQUFTLEVBQUUsUUFBUSxDQUFDLENBQUE7UUFDbEUsb0JBQW9CLEdBQUcsb0JBQW9CLEdBQUcsU0FBUyxHQUFHLElBQUksQ0FBQTtJQUNsRSxDQUFDO0lBQ0QsTUFBTSxDQUFDLG9CQUFvQixDQUFBO0FBQy9CLENBQUMsQ0FBQSJ9
|
48
dist/beautylog.log.d.ts
vendored
Normal file
48
dist/beautylog.log.d.ts
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
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
Normal file
8
dist/beautylog.log.helpers.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
*
|
||||
* @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
Normal file
107
dist/beautylog.log.helpers.js
vendored
Normal file
File diff suppressed because one or more lines are too long
80
dist/beautylog.log.js
vendored
Normal file
80
dist/beautylog.log.js
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
"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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLmxvZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2JlYXV0eWxvZy5sb2cudHMiXSwibmFtZXMiOltdLCJtYXBwaW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BQUssRUFBQyxPQUFPLENBQUMsQ0FBQTtBQUNyQyxDQUFDLENBQUE7QUFFRDs7OztHQUlHO0FBQ1EsUUFBQSxPQUFPLEdBQUcsQ0FBQyxXQUFtQixDQUFDO0lBQ3RDLEdBQUcsQ0FBQyxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLEdBQUcsUUFBUSxFQUFFLENBQUMsRUFBRSxFQUFFLENBQUM7UUFDaEMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsQ0FBQTtJQUNyQixDQUFDO0FBQ0wsQ0FBQyxDQUFBO0FBRUQ7O0dBRUc7QUFDUSxRQUFBLFVBQVUsR0FBRyxDQUFDLFVBQWtCLEVBQUMsc0JBQThCLENBQUM7SUFDdkUsRUFBRSxDQUFDLENBQUMsVUFBVSxLQUFLLGVBQWUsSUFBSSxDQUFDLG1CQUFtQixLQUFLLENBQUMsSUFBSSxrQkFBa0IsS0FBSyxtQkFBbUIsQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUM5RyxrQkFBa0IsRUFBRSxDQUFBO0lBQ3hCLENBQUM7SUFBQyxJQUFJLENBQUMsQ0FBQztRQUNKLGtCQUFrQixHQUFHLENBQUMsQ0FBQTtRQUN0QixlQUFlLEdBQUcsVUFBVSxDQUFBO1FBQzVCLFdBQUcsQ0FBQyxVQUFVLENBQUMsQ0FBQTtJQUNuQixDQUFDO0FBQ0wsQ0FBQyxDQUFBO0FBQ0QsSUFBSSxlQUFlLEdBQVcsRUFBRSxDQUFBO0FBQ2hDLElBQUksa0JBQWtCLEdBQVcsQ0FBQyxDQUFBIn0=
|
9
dist/beautylog.plugins.d.ts
vendored
Normal file
9
dist/beautylog.plugins.d.ts
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
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
Normal file
17
dist/beautylog.plugins.js
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
"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
Normal file
4
dist/beautylog.register.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* registers a remote
|
||||
*/
|
||||
export declare let registerRemote: any;
|
2
dist/beautylog.register.js
vendored
Normal file
2
dist/beautylog.register.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLnJlZ2lzdGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvYmVhdXR5bG9nLnJlZ2lzdGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
9
dist/beautylog.remote.d.ts
vendored
Normal file
9
dist/beautylog.remote.d.ts
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
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
Normal file
32
dist/beautylog.remote.js
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
"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,eyJ2ZXJzaW9uIjozLCJmaWxlIj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0FBQ2pELENBQUMsQ0FBQTtBQUVVLFFBQUEsTUFBTSxHQUFHO0lBQ2hCLE1BQU0sRUFBRSxNQUFNO0NBQ2pCLENBQUEifQ==
|
6
dist/index.d.ts
vendored
Normal file
6
dist/index.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
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
Normal file
23
dist/index.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
"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
|
15
docs/book.json
Normal file
15
docs/book.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"structure": {
|
||||
"readme": "index.md"
|
||||
},
|
||||
"plugins": [
|
||||
"tonic",
|
||||
"edit-link"
|
||||
],
|
||||
"pluginsConfig": {
|
||||
"edit-link": {
|
||||
"base": "https://gitlab.com/pushrocks/beautylog/edit/master/docs/",
|
||||
"label": "Edit on GitLab"
|
||||
}
|
||||
}
|
||||
}
|
115
docs/index.md
115
docs/index.md
@ -1,74 +1,101 @@
|
||||
# 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/)
|
||||
[](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://www.npmjs.com/package/beautylog)
|
||||
[](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/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Quick Demo
|
||||
|
||||
[](https://asciinema.org/a/46djsde96ecsho9wqibjx2zye)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
```typescript
|
||||
import * as beautylog from "beautylog";
|
||||
|
||||
```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
|
||||
```
|
||||
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.
|
||||
|
||||
```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();
|
||||
```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
|
||||
```
|
||||
|
||||
#### 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.
|
||||
|
||||
```javascript
|
||||
import { Loggly } from 'beautyremote';
|
||||
let myLogglyRemote = new Loggly({
|
||||
token: 'my_super_long_token_here',
|
||||
Currently supported remote providers:
|
||||
|
||||
* loggly.com
|
||||
|
||||
```typescript
|
||||
beautylog.remote.loggly({
|
||||
token: "loggly-token",
|
||||
subdomain: "loggly-subdomain",
|
||||
appName: "some App Name",
|
||||
serverName: "some Server Name"
|
||||
});
|
||||
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.
|
||||
> 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 further information read the linked docs at the top of this README.
|
||||
For more information read the docs!
|
||||
|
||||
> 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)
|
||||
[](https://push.rocks)
|
||||
|
@ -1,28 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
4
npmts.json
Normal file
4
npmts.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"mode":"default",
|
||||
"coveralls":true
|
||||
}
|
80
package.json
80
package.json
@ -1,59 +1,51 @@
|
||||
{
|
||||
"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",
|
||||
"name": "beautylog",
|
||||
"version": "6.0.6",
|
||||
"description": "beautiful logging, TypeScript ready",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild --web)",
|
||||
"buildDocs": "tsdoc"
|
||||
"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)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://code.foss.global/push.rocks/smartlog-destination-local.git"
|
||||
"url": "https://gitlab.com/pushrocks/beautylog.git"
|
||||
},
|
||||
"keywords": [
|
||||
"logging",
|
||||
"console log",
|
||||
"log management",
|
||||
"developer tools",
|
||||
"local logging",
|
||||
"console output"
|
||||
"log",
|
||||
"color",
|
||||
"console",
|
||||
"beautiful"
|
||||
],
|
||||
"author": "Lossless GmbH <hello@lossless.com> (https://lossless.com)",
|
||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/pushrocks/beautylog/issues"
|
||||
},
|
||||
"homepage": "https://code.foss.global/push.rocks/smartlog-destination-local",
|
||||
"homepage": "https://gitlab.com/pushrocks/beautylog",
|
||||
"dependencies": {
|
||||
"@push.rocks/consolecolor": "^2.0.1",
|
||||
"@push.rocks/smartlog-interfaces": "^3.0.0",
|
||||
"@push.rocks/smartpromise": "^4.0.2"
|
||||
"@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"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@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"
|
||||
]
|
||||
}
|
||||
"npmts-g": "^6.0.0",
|
||||
"qenv": "^1.1.3",
|
||||
"smartchai": "^1.0.1",
|
||||
"typings-test": "^1.0.3"
|
||||
}
|
||||
}
|
||||
|
5009
pnpm-lock.yaml
generated
5009
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@
|
||||
|
111
readme.md
111
readme.md
@ -1,111 +0,0 @@
|
||||
# @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.
|
25179
test/browser/browserified/index.js
Normal file
25179
test/browser/browserified/index.js
Normal file
File diff suppressed because it is too large
Load Diff
6
test/browser/index.html
Normal file
6
test/browser/index.html
Normal file
@ -0,0 +1,6 @@
|
||||
<head>
|
||||
<script async src="browserified/index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
4
test/browser/index.js
Normal file
4
test/browser/index.js
Normal file
@ -0,0 +1,4 @@
|
||||
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
Normal file
1
test/test.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
import 'typings-test';
|
88
test/test.js
Normal file
88
test/test.js
Normal file
@ -0,0 +1,88 @@
|
||||
"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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQiwyQ0FBMkM7QUFJM0MsUUFBUSxDQUFDLFdBQVcsRUFBQztJQUNqQixRQUFRLENBQUMsZUFBZSxFQUFDO1FBQ3JCLEVBQUUsQ0FBQyxpQ0FBaUMsRUFBQztZQUNqQyxTQUFTLENBQUMsR0FBRyxDQUFDLHVEQUF1RCxDQUFDLENBQUE7UUFDMUUsQ0FBQyxDQUFDLENBQUE7SUFDTixDQUFDLENBQUMsQ0FBQTtJQUNGLFFBQVEsQ0FBQyxlQUFlLEVBQUM7UUFDckIsRUFBRSxDQUFDLGlDQUFpQyxFQUFDO1lBQ2pDLFNBQVMsQ0FBQyxHQUFHLENBQUMsdURBQXVELENBQUMsQ0FBQTtRQUMxRSxDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0lBQ0YsUUFBUSxDQUFDLGlCQUFpQixFQUFDO1FBQ3ZCLEVBQUUsQ0FBQyxrQ0FBa0MsRUFBQztZQUNsQyxTQUFTLENBQUMsS0FBSyxDQUFDLHlEQUF5RCxDQUFDLENBQUE7UUFDOUUsQ0FBQyxDQUFDLENBQUE7SUFDTixDQUFDLENBQUMsQ0FBQTtJQUNGLFFBQVEsQ0FBQyxTQUFTLEVBQUM7UUFDZixFQUFFLENBQUMsOENBQThDLEVBQUMsVUFBUyxJ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UFDLENBQUE7UUFDRixFQUFFLENBQUMsdURBQXVELEVBQUMsVUFBUyxJQUFJO1lBQ3BFLElBQUksQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUE7WUFDbkIsSUFBSSxPQUFPLEdBQUcsSUFBSSxTQUFTLENBQUMsR0FBRyxDQUFDLDJCQUEyQixFQUFDLE9BQU8sQ0FBQyxDQUFBO1lBQ3BFLFVBQVUsQ0FBQztnQkFDUCxPQUFPLENBQUMsUUFBUSxDQUFDLGtDQUFrQyxDQUFDLENBQUE7Z0JBQ3BELElBQUksRUFBRSxDQUFBO1lBQ1YsQ0FBQyxFQUFDLElBQUksQ0FBQyxDQUFBO1FBQ1gsQ0FBQyxDQUFDLENBQUE7SUFDTixDQUFDLENBQUMsQ0FBQTtJQUNGLFFBQVEsQ0FBQyxtQkFBbUIsRUFBQztRQUN6QixFQUFFLENBQUMsdUNBQXVDLEVBQUM7WUFDdkMsU0FBUyxDQUFDLE9BQU8sQ0FBQywyREFBMkQsQ0FBQyxDQUFBO1FBQ2xGLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7SUFDRixRQUFRLENBQUMsT0FBTyxFQUFDO1FBQ2IsRUFBRSxDQUFDLHNDQUFzQyxFQUFDO1lBQ3RDLFNBQVMsQ0FBQyxJQUFJLENBQUMsd0RBQXdELENBQUMsQ0FBQTtRQUM1RSxDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ==
|
134
test/test.ts
134
test/test.ts
@ -1,49 +1,89 @@
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
import 'typings-test'
|
||||
import beautylog = require('../dist/index')
|
||||
|
||||
import * as smartlogDesinationLocal from '../ts/index.js';
|
||||
import type { ILogContext } from '@push.rocks/smartlog-interfaces';
|
||||
import * as qenv from 'qenv'
|
||||
|
||||
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();
|
||||
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')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -1,8 +0,0 @@
|
||||
/**
|
||||
* 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'
|
||||
}
|
52
ts/beautylog.classes.ora.ts
Normal file
52
ts/beautylog.classes.ora.ts
Normal file
@ -0,0 +1,52 @@
|
||||
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()
|
||||
}
|
||||
}
|
40
ts/beautylog.console.ts
Normal file
40
ts/beautylog.console.ts
Normal file
@ -0,0 +1,40 @@
|
||||
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)
|
61
ts/beautylog.figlet.ts
Normal file
61
ts/beautylog.figlet.ts
Normal file
@ -0,0 +1,61 @@
|
||||
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
|
||||
}
|
109
ts/beautylog.log.helpers.ts
Normal file
109
ts/beautylog.log.helpers.ts
Normal file
@ -0,0 +1,109 @@
|
||||
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
|
||||
}
|
||||
}
|
88
ts/beautylog.log.ts
Normal file
88
ts/beautylog.log.ts
Normal file
@ -0,0 +1,88 @@
|
||||
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
|
19
ts/beautylog.plugins.ts
Normal file
19
ts/beautylog.plugins.ts
Normal file
@ -0,0 +1,19 @@
|
||||
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
|
||||
}
|
4
ts/beautylog.register.ts
Normal file
4
ts/beautylog.register.ts
Normal file
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* registers a remote
|
||||
*/
|
||||
export let registerRemote
|
38
ts/beautylog.remote.ts
Normal file
38
ts/beautylog.remote.ts
Normal file
@ -0,0 +1,38 @@
|
||||
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
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
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,2 +1,11 @@
|
||||
import 'typings-global'
|
||||
import './beautylog.console'
|
||||
|
||||
import * as plugins from './beautylog.plugins'
|
||||
// export classes
|
||||
export { DestinationLocal } from './classes.destinationlocal.js';
|
||||
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'
|
||||
|
@ -1,5 +0,0 @@
|
||||
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 };
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
3
tslint.json
Normal file
3
tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user