improve README and test registerRemote

This commit is contained in:
Philipp Kunz 2017-01-22 11:42:04 +01:00
parent 56a7ab7858
commit 62f2f23522
5 changed files with 35 additions and 19 deletions

View File

@ -29,40 +29,32 @@ 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:
![console.png](https://mediaserve.lossless.digital/github.com/pushrocks/beautylog/console.png)
### 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
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
myOra.text('some updated text')
myOra.stop()
beautylog.ora.text('some updated text') // switches the text
beautylog.ora.stop()
```
## Centralized remote logging
Beautylog makes it easy to have all your node applications log to a remote location.
Currently supported remote providers:
* loggly.com
```typescript
beautylog.remote.loggly({
token: 'loggly-token',
subdomain: 'loggly-subdomain',
appName: 'some App Name',
serverName: 'some Server Name'
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.
> 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 loggly as well.
Everything that is getting logged to your console by node will get logged to a remote as well.
For more information read the docs!

View File

@ -41,6 +41,7 @@
"typings-global": "^1.0.14"
},
"devDependencies": {
"beautyremote": "^1.0.2",
"npmts-g": "^6.0.0",
"qenv": "^1.1.3",
"smartchai": "^1.0.1",

2
qenv.yml Normal file
View File

@ -0,0 +1,2 @@
vars:
- LOGGLY_TOKEN

View File

@ -1,7 +1,18 @@
"use strict";
require("typings-test");
const beautylog = require("../dist/index");
const beautyremote = require("beautyremote");
const qenv = require("qenv");
let testQenv = new qenv.Qenv(process.cwd(), process.cwd() + '/.nogit');
describe('beautylog', function () {
describe('.registerRemote', function () {
it('should accept a beautyremote', function () {
let myRemote = new beautyremote.Loggly({
token: process.env.LOGGLY_TOKEN
});
beautylog.registerRemote(myRemote);
});
});
describe('.log(message)', function () {
it('should print a blue Dir message', function () {
beautylog.log('beautylog.log(), with normal logText, without logType');
@ -90,4 +101,4 @@ describe('beautylog', function () {
});
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQiwyQ0FBMkM7QUFJM0MsUUFBUSxDQUFDLFdBQVcsRUFBQztJQUNqQixRQUFRLENBQUMsZUFBZSxFQUFDO1FBQ3JCLEVBQUUsQ0FBQyxpQ0FBaUMsRUFBQztZQUNqQyxTQUFTLENBQUMsR0FBRyxDQUFDLHVEQUF1RCxDQUFDLENBQUE7UUFDMUUsQ0FBQyxDQUFDLENBQUE7SUFDTixDQUFDLENBQUMsQ0FBQTtJQUNGLFFBQVEsQ0FBQyxlQUFlLEVBQUM7UUFDckIsRUFBRSxDQUFDLGlDQUFpQyxFQUFDO1lBQ2pDLFNBQVMsQ0FBQyxHQUFHLENBQUMsdURBQXVELENBQUMsQ0FBQTtRQUMxRSxDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0lBQ0YsUUFBUSxDQUFDLGlCQUFpQixFQUFDO1FBQ3ZCLEVBQUUsQ0FBQyxrQ0FBa0MsRUFBQztZQUNsQyxTQUFTLENBQUMsS0FBSyxDQUFDLHlEQUF5RCxDQUFDLENBQUE7UUFDOUUsQ0FBQyxDQUFDLENBQUE7SUFDTixDQUFDLENBQUMsQ0FBQTtJQUNGLFFBQVEsQ0FBQyxTQUFTLEVBQUM7UU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LENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7SUFDRixRQUFRLENBQUMsT0FBTyxFQUFFO1FBQ2QsRUFBRSxDQUFDLDRCQUE0QixFQUFFO1lBQzdCLFNBQVMsQ0FBQyxJQUFJLENBQUMseUJBQXlCLENBQUMsQ0FBQTtRQUM3QyxDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ==

View File

@ -1,9 +1,19 @@
import 'typings-test'
import beautylog = require('../dist/index')
import * as beautyremote from 'beautyremote'
import * as qenv from 'qenv'
let testQenv = new qenv.Qenv(process.cwd(), process.cwd() + '/.nogit')
describe('beautylog',function(){
describe('.registerRemote', function() {
it('should accept a beautyremote', function(){
let myRemote = new beautyremote.Loggly({
token: process.env.LOGGLY_TOKEN
})
beautylog.registerRemote(myRemote)
})
})
describe('.log(message)',function(){
it('should print a blue Dir message',function(){
beautylog.log('beautylog.log(), with normal logText, without logType')