Skip to content

Commit

Permalink
doc: [README] updated
Browse files Browse the repository at this point in the history
  • Loading branch information
glennprofile committed Jan 13, 2020
1 parent f17cfc7 commit 4ad6416
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 56 deletions.
28 changes: 28 additions & 0 deletions README-DEV.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# DEVELOP

## how to build
- yarn dev
- yarn prod

## 如何利用 yarn link 做開發中的專案鏈結
```
cd /var/www/library-app
yarn link
> success Registered "library-app"
cd /var/www/your-main-project
yarn link "library-app"
> success Using linked package for "library-app"
yarn unlink "library-app"
> success Removed linked package "library-app"
```

## API dependency
- Loggly fetch url API

## node dependency
- yarn add cross-fetch

## webpack dependency
- yarn add dotenv-webpack
43 changes: 9 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,41 @@
## feature
- send log to Loggly

## how to build
- yarn dev
- yarn prod

## laravel dependency
- .env
- .env.example

## API dependency
- Loggly fetch url API

## node dependency
- yarn add cross-fetch

## webpack dependency
- yarn add dotenv-webpack
## how to install
- yarn add universal-loggly

## include example
- vi /your-project/app.js
```js
// from origin
// for library
import { LogglyClient } from 'universal-loggly';

// from custom helper
// you can custom myself helper
import { factoryLogglyClient } from 'universal-loggly-helper';
```

## sample code
```js
import { factoryLogglyClient } from 'universal-loggly-helper';

const logger = factoryLogglyClient();
const message = 'test message';
const redirectUrl = 'https://duckduckgo.com/';
const promise = logger.info(message);
const promise = logger.info(message, {
extend_content: true,
});

promise.then(function(data) {
// success
})
.catch(function(error) {
// skip
console.error(`[universal-loggly]: ${error}`);
})
.finally(function() {
window.location.href = redirectUrl;
});
```

## for develop library
```
cd /var/www/library-app
yarn link
> success Registered "library-app"
cd /var/www/your-main-project
yarn link "library-app"
> success Using linked package for "library-app"
yarn unlink "library-app"
> success Removed linked package "library-app"
```

## plan of future
- ES8 async/await
- storage cookie
Expand Down
22 changes: 0 additions & 22 deletions example/universal-loggly-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,9 @@ function getToken_2() {
return LOGGLYPLUS_TOKEN;
}

// factoryLogger()
export function factoryLogglyClient() {
const token = getToken();

const logger = new LogglyClient(token, tags);
return logger;
}

/*
const logger = factoryLogglyClient();
const message = 'test message';
const promise = logger.info(message, {
redirect_result: true,
redirect_url: 'https://127.0.0.1',
});
promise
.then(function(data) {
console.log('log ok');
})
.catch(function(error) {
console.error(`[universal-loggly]: ${error}`);
})
.finally(function() {
console.log('log final');
});
*/

0 comments on commit 4ad6416

Please sign in to comment.