Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lme

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lme - npm Package Compare versions

Comparing version 1.3.2 to 1.4.0

.vscode/settings.json

38

index.js
'use strict';
var chalk = require('chalk');
var logUtil = require('./logUtil');
var linesUtil = require('./linesUtil');
var config = require('./config');

@@ -13,28 +13,28 @@ var m = {

// default
d: function(msg) {
logUtil.logWithColor(chalk.white, msg);
d: function() {
logUtil.logWithColor(config.colors.logs.default, arguments);
},
// success
s: function(msg) {
logUtil.logWithColor(chalk.bold.green, msg);
s: function() {
logUtil.logWithColor(config.colors.logs.success, arguments);
},
// warning
w: function(msg) {
logUtil.logWithColor(chalk.bgYellow.black, msg);
w: function() {
logUtil.logWithColor(config.colors.logs.warning, arguments);
},
// err
e: function(msg) {
logUtil.logWithColor(chalk.bgRed.white, msg);
e: function() {
logUtil.logWithColor(config.colors.logs.error, arguments);
},
// highlight
h: function(msg) {
logUtil.logWithColor(chalk.bgCyan.black, msg);
h: function() {
logUtil.logWithColor(config.colors.logs.highlight, arguments);
},
//info
i: function(msg) {
logUtil.logWithColor(chalk.bold.cyan, msg);
i: function() {
logUtil.logWithColor(config.colors.logs.info, arguments);
},
//trace:
t: function(msg) {
logUtil.logTraceWithColor(chalk.green, msg);
t: function() {
logUtil.logTraceWithColor(config.colors.logs.trace, arguments);
},

@@ -56,15 +56,15 @@

sline: function(char, length) {
linesUtil.logLine(char, length, this.e, this.w, chalk.bold.green);
linesUtil.logLine(char, length, this.e, this.w, config.colors.logs.success);
},
// warning
wline: function(char, length) {
linesUtil.logLine(char, length, this.e, this.w, chalk.bgYellow.black);
linesUtil.logLine(char, length, this.e, this.w, config.colors.logs.warning);
},
// error
eline: function(char, length) {
linesUtil.logLine(char, length, this.e, this.w, chalk.bgRed.white);
linesUtil.logLine(char, length, this.e, this.w, config.colors.logs.error);
},
// highlight
hline: function(char, length) {
linesUtil.logLine(char, length, this.e, this.w, chalk.bgCyan.black);
linesUtil.logLine(char, length, this.e, this.w, config.colors.logs.highlight);
}

@@ -71,0 +71,0 @@ };

@@ -8,3 +8,3 @@ var defaultChar = '-';

} else if (typeof(char) == 'object') {
errLogFunc("ERROR: the line() functions can't accept objects!");
errLogFunc('ERROR: the line() functions can\'t accept objects!');
char = defaultChar; //continue working with default behaviour.

@@ -16,3 +16,3 @@ }

function getLength(length, warnLogFunc) {
function getLength(length/*, warnLogFunc*/) {
if (!length) {

@@ -22,3 +22,3 @@ length = defaultLength;

// warnLogFunc("WARNING: ");
};
}

@@ -29,7 +29,7 @@ return length;

function buildLine(char, length) {
var theLine = "";
var theLine = '';
for (var i = 0; i < length; i++) {
theLine = theLine + char;
};
return theLine
}
return theLine;
}

@@ -55,3 +55,3 @@

module.exports = {
logLine
}
logLine: logLine
};

@@ -1,22 +0,35 @@

function logWithColor(colorFunc, msg) {
logMessage(colorFunc, msg, console.log);
function getMessageArgs(args) {
args = Array.prototype.slice.call(args, 1);
return Array.prototype.slice.call(args[0]);
}
function logTraceWithColor(colorFunc, msg) {
console.log(colorFunc("\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< BEGIN"));
logMessage(colorFunc, msg, console.trace);
console.log(colorFunc(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>> END\n"));
function logWithColor(colorFunc) {
var args = getMessageArgs(arguments);
logMessage(colorFunc, args, console.log);
}
function logMessage(colorFunc, msg, consoleFunc) {
if (typeof(msg) == 'object') {
consoleFunc(colorFunc('\n' + JSON.stringify(msg, null, 2)));
} else {
consoleFunc(colorFunc(msg));
}
function logTraceWithColor(colorFunc) {
var args = getMessageArgs(arguments);
console.log(colorFunc('\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< BEGIN'));
logMessage(colorFunc, args, console.trace);
console.log(colorFunc('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> END\n'));
}
function logMessage(colorFunc, msgArgs, consoleFunc) {
var outputArgs = [];
msgArgs.forEach(function(arg) {
if (typeof(arg) == 'object') {
outputArgs.push('\n' + JSON.stringify(arg, null, 2));
} else {
outputArgs.push(arg);
}
});
consoleFunc(colorFunc.apply(this, outputArgs));
}
module.exports = {
logWithColor,
logTraceWithColor
}
logWithColor: logWithColor,
logTraceWithColor: logTraceWithColor
};
{
"name": "lme",
"version": "1.3.2",
"version": "1.4.0",
"description": "Simply and beautifully log to console.",
"main": "index.js",
"scripts": {
"test": "node test.js"
"test": "node test.js",
"lint": "eslint ."
},

@@ -29,2 +30,3 @@ "repository": {

"dependencies": {
"app-root-path": "^2.0.1",
"chalk": "^1.1.3"

@@ -35,4 +37,6 @@ },

"Aman Mittal (https://github.com/amandeepmittal)"
]
],
"devDependencies": {
"eslint": "^3.13.1"
}
}

@@ -0,1 +1,3 @@

[![Build Status](https://travis-ci.org/vajahath/lme.svg?branch=stable)](https://travis-ci.org/vajahath/lme)
![](https://raw.githubusercontent.com/vajahath/lme/master/media/logo.png)

@@ -12,6 +14,8 @@

> **v1.4** is out. **What's new?**<br>
> **-** Now [define your own color schemes](#custom-color-schemes)! <br>
> **-** Multiple argumnets support: _`lme.s("hi", "hello")`_ <br>
> **-** Stability and performance improvements.
> **version 1.3** is out with serious improvements. [Update](#install--update) to get most out of `lme`. See [change log](#change-log) for more details.
## Why `lme` *( logme )*

@@ -21,2 +25,3 @@ - Simpler to use than `console.log()` or even `console.log(chalk.red("hi"));`

- Automatically expands `objects` and `arrays`. So that, you don't have to use `JSON.stringify()` anymore.
- **[Define your own color schemes](#custom-color-schemes)** with `lmeconfig.json` file.
- Clean and semantically focused.

@@ -65,3 +70,3 @@ - Actively maintained.

| status | name | when to use | example |
| ------------- | ---------- | -------------------------- | --------------------- |
| :------------ | :--------- | :------------------------- | :-------------------- |
| `d` | default | default output | `lme.d("hi");` |

@@ -79,5 +84,10 @@ | `s` | success | on success output | `lme.s("hi");` |

You can also use multiple arguments with `lme` like:
```js
lme.d(message[, message]);
```
## Drawing lines with `lme.line()`
**Syntax :** `lme.line(character, length)`.
**Syntax :** `lme.line(character, length)`. (both arguments are optional)

@@ -89,3 +99,3 @@ You can prefix `d`, `s`, `e`, `w`, `h` to the `line()` function to obtain the corresponding color scheme for your line. You can also simply use `lme.line()` which has some default values as described below.

| argument | type | purpose | default value |
| --------------- | ---------- | ----------------------------------------------------------- | ---------------- |
| :-------------- | :--------- | :---------------------------------------------------------- | :--------------- |
| `character` | `string` | determines which character should be used for drawing lines | `-` |

@@ -108,3 +118,3 @@ | `length` | `integer` | length of the line | 30 |

| status | name | when to use | example |
| ----------------- | --------------- | -------------------------- | ------------------------- |
| :---------------- | :-------------- | :------------------------- | :------------------------ |
| `line` | default | default output | `lme.line();` |

@@ -117,2 +127,96 @@ | `dline` | same as line | default output | `lme.dline("*", 5);` |

## Custom Color Schemes
You can add your own color scheme to your project and make it unique! It's simple. Here is how:
1. Go to your application root directory
2. Create an `lmeconfig.json` file there with the following content.
3. Restart your application.
### Content of `lmeconfig.json`
Basically, this file describes your configurations that the `lme` should follow. If no such valid files are found at the application root, it will follow the default configurations.
Below is an example `lmeconfig.json`:
```json
{
"colors": {
"logs": {
"default": ["red"],
"error": ["bgRed", "cyan"]
}
}
}
```
This configuration will overwrite the default configurations.
So,
- when you use `lme.d("hi")` next time, it will be in **red**.
- when you use `lme.e("hi")` next time, text-color will be **cyan** and background-color will be **red**.
- the changes will also be reflected in corresponding line functions. In this case, `lme.line()`, `lme.dline()`, `lme.eline()`.
- Nothing else will be changed.
### Possible values in `lmeconfig.json`
#### Styling
| Available colors | Background colors | Modifiers |
| :----------------- | :------------------- | :-------------------------------------- |
| `black` | `bgBlack` | `reset` |
| `red` | `bgRed` | `bold` |
| `green` | `bgGreen` | `dim` |
| `yellow` | `bgYellow` | `italic` (not widely supported) |
| `blue` | `bgMagenta` | `underline` |
| `magenta` | `bgCyan` | `inverse` |
| `cyan` | `bgWhite` | `hidden` |
| `white` | `bgBlue` |`strikethrough` (not widely supported) |
| `gray` |
You can specify multiple styles for a text by mentioning it as an `Array`.
Example:
```json
{
"colors": {
"logs": {
"error": ["bgRed", "cyan", "bold"]
}
}
}
```
#### Properties and its jobs
Below is the list of all properties and its jobs that the `lmeconfig.json` file can have.
| Properties | what it does? |
| :----------------------- | :--------------- |
| `colors.logs.default` | styles `lme.d()` |
| `colors.logs.success` | styles `lme.s()` |
| `colors.logs.error` | styles `lme.e()` |
| `colors.logs.warning` | styles `lme.w()` |
| `colors.logs.highlight` | styles `lme.h()` |
| `colors.logs.info` | styles `lme.i()` |
| `colors.logs.trace` | styles `lme.t()` |
### Default configurations
You can find default configurations in
```bash
./node_modules/lme/lmeDefaultConfig.json
```
> **Note:** It is not recommended to alter this file. If you need to change it, adding an `lmeconfig.json` file at the application root directory is equivalent and safe.
here is an example:
```json
{
"colors": {
"logs": {
"default": ["white"],
"success": ["bold", "green"],
"warning": ["bgYellow", "black"],
"error": ["bgRed", "white"],
"highlight": ["bgCyan", "black"],
"info": ["bold", "cyan"],
"trace": ["green"]
}
}
}
```
<br>

@@ -129,3 +233,18 @@ <br>

## Thanks
Thanks to everyone who contributed to this project by means of providing feedback, rising issues, opening pull requests and reviewing codes.
Thanks for using `lme`.
#### Contributors
- [@demacdonald](https://github.com/demacdonald)
- [@amandeepmittal](https://github.com/amandeepmittal)
#### Loves lme? _tell your friends.._
## Change log
- **v1.4.0** (26th Jan 2017)
- Added support for custom color configuration.
- Added support for multiple arguments. (*thanks [@demacdonald](https://github.com/demacdonald)*)
- Stability and performance improvements.
- v1.3.1, v1.3.2

@@ -132,0 +251,0 @@ + Docs update.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc