...
 
Commits (2)
......@@ -12,11 +12,22 @@ import { Error, Warn, ... } from 'log74';
Error("error message");
```
## Web usage
## Web usage (webpack / tsc / etc)
Include: `<script src="https://unpkg.com/log74@1.0.0/dist/index.web.js"></script>`
Install like above.
```javascript
import { Error, Warn, ... } from 'log74/dist/index.web';
Error("error message");
```
## Web usage (global script import)
Include: `<script src="https://unpkg.com/log74@1.0.3/dist/index.webpack.js"></script>`
```javascript
// functions are bound to window object
Error("error message");
```
......@@ -18,7 +18,7 @@
"prod:node": "tsc"
},
"name": "log74",
"version": "1.0.2",
"version": "1.0.3",
"description": "Mini logging library for Node.js and the web.",
"main": "dist/index.node.js",
"repository": "https://gitlab.insrt.uk/insert/log74.git",
......
......@@ -4,7 +4,7 @@ import Logger from './common/logger';
/**
* Write an error message
*/
function Error(string: string, cb?: Result) {
export function Error(string: string, cb?: Result) {
console.error(`%c✖ ERR %c${string}`, 'color: red; font-size: 1.6em', 'color: white');
cb && cb(`ERR: ${string}`);
}
......@@ -12,7 +12,7 @@ function Error(string: string, cb?: Result) {
/**
* Write a warning message
*/
function Warn(string: string, cb?: Result) {
export function Warn(string: string, cb?: Result) {
console.warn(`%c⚠ WARN %c${string}`, 'color: yellow; font-size: 1.6em', 'color: white');
cb && cb(`WARN: ${string}`);
}
......@@ -20,7 +20,7 @@ function Warn(string: string, cb?: Result) {
/**
* Write an info message
*/
function Info(string: string, cb?: Result) {
export function Info(string: string, cb?: Result) {
console.info(`%cℹ️ INFO %c${string}`, 'color: #6298ef; font-size: 1.6em', 'color: white');
cb && cb(`WARN: ${string}`);
}
......@@ -28,7 +28,7 @@ function Info(string: string, cb?: Result) {
/**
* Write a success message
*/
function Success(string: string, cb?: Result) {
export function Success(string: string, cb?: Result) {
console.info(`%c✔️ SUCCESS %c${string}`, 'color: green; font-size: 1.6em', 'color: white');
cb && cb(`SUCCESS: ${string}`);
}
......@@ -36,7 +36,7 @@ function Success(string: string, cb?: Result) {
/**
* Write a 'notice' message
*/
function Log(string: string, cb?: Result) {
export function Log(string: string, cb?: Result) {
console.info(`%cLOG %c${string}`, 'color: gray; font-size: 1.6em', 'color: white');
cb && cb(`LOG: ${string}`);
}
......@@ -44,7 +44,7 @@ function Log(string: string, cb?: Result) {
/**
* Logger class with custom message handler
*/
class WebLogger extends Logger {
export class WebLogger extends Logger {
error(string: string) {Error(string, this.l)};
warn(string: string) {Warn(string, this.l)};
info(string: string) {Info(string, this.l)};
......
import * as web from './index.web';
const win: any = window;
win.Error = web.Error;
win.Warn = web.Warn;
win.Info = web.Info;
win.Success = web.Success;
win.Log = web.Log;
win.Logger = web.WebLogger;
\ No newline at end of file
......@@ -59,6 +59,7 @@
},
"include": [
"src/index.node.ts",
"src/index.web.ts",
"src/common/**/*.ts"
]
}
\ No newline at end of file
const path = require('path');
module.exports = {
entry: './src/index.web.ts',
entry: './src/index.webpack.ts',
output: {
filename: 'index.web.js',
filename: 'index.webpack.js',
path: path.resolve(__dirname, 'dist')
},
module: {
......