-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from OnrampLab/feat-1-init
Feat 1 init
- Loading branch information
Showing
18 changed files
with
1,458 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
# 2 space indentation | ||
[**.*] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules/ | ||
dist/ | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# universal-loggly | ||
|
||
## 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 | ||
|
||
## include example | ||
- vi /your-project/app.js | ||
```js | ||
// from origin | ||
import { LogglyClient } from 'universal-loggly'; | ||
|
||
// from custom helper | ||
import { factoryLogglyClient } from 'universal-loggly-helper'; | ||
``` | ||
|
||
## sample code | ||
```js | ||
import { factoryLogglyClient } from 'universal-loggly-helper'; | ||
|
||
const message = 'test message'; | ||
const redirectUrl = 'https://duckduckgo.com/'; | ||
const promise = logger.info(message); | ||
|
||
promise.then(function(data) { | ||
// success | ||
}) | ||
.catch(function(error) { | ||
// skip | ||
}) | ||
.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 | ||
- send hook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Demo</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import getConfig from "next/config"; | ||
import { LogglyClient } from "universal-loggly"; | ||
|
||
const tags = "localhost, staging, test-only"; | ||
|
||
function getToken() { | ||
return process.env.LOGGLYPLUS_TOKEN; | ||
} | ||
|
||
function getToken_2() { | ||
const { publicRuntimeConfig } = getConfig() || {}; | ||
const { LOGGLYPLUS_TOKEN } = publicRuntimeConfig || {}; | ||
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'); | ||
}); | ||
*/ |
Oops, something went wrong.