Socket
Socket
Sign inDemoInstall

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

Simply and beautifully log to console.


Version published
Maintainers
1
Created
Source

Build Status

console.log ging done right, beautifully.

You don't have to write the 13 char long console.log() anymore. Try:

lme.d("hello world");

v1.4 is out. What's new?
- Now define your own color schemes!
- Multiple argumnets support: lme.s("hi", "hello")
- Stability and performance improvements.

Why lme ( logme )

  • Simpler to use than console.log() or even console.log(chalk.red("hi"));
  • Draw lines with just a single function, lme.line().
  • Automatically expands objects and arrays. So that, you don't have to use JSON.stringify() anymore.
  • Define your own color schemes with lmeconfig.json file.
  • Clean and semantically focused.
  • Actively maintained.
  • Consistent design for errors, warnings, successes etc.

Install / Update

npm install --save lme

Usage

Syntax

lme.<status>(message);

Example

const lme = require('lme');

lme.d("my kitty is pinky!"); // default style, used for anonymous outputs.
lme.e("Snap! something went wrong."); // used for logging errors.
lme.s("Oh yeah!"); // used for logging success.
lme.w("Attention! Thank you for your attention."); // used for logging warnings.

// lines
lme.line() // used to draw lines
lme.eline() // used to draw lines in error theme.
lme.sline() // used to draw lines in success theme.

APIs

Syntax : lme.<status>(message);

  • where <status> can have the following values:
statusnamewhen to useexample
ddefaultdefault outputlme.d("hi");
ssuccesson success outputlme.s("hi");
eerroron error-ed outputlme.e("hi");
wwarningfor warnings like outputlme.w("hi");
hhighlightfor highlighting an outputlme.h("hi");
iinfofor info like outputlme.i("hi");
ttracefor tracing stacklme.t("hi");

where message can be string / float / int / objects. (note that javascript treats arrays as objects.)

You can also use multiple arguments with lme like:

lme.d(message[, message]);

Drawing lines with lme.line()

Syntax : lme.line(character, length). (both arguments are optional)

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 List

argumenttypepurposedefault value
characterstringdetermines which character should be used for drawing lines-
lengthintegerlength of the line30

Examples

lme.line();
lme.eline("^");
lme.sline("@", 12);
lme.wline("#", 50);

APIs for drawing lines

statusnamewhen to useexample
linedefaultdefault outputlme.line();
dlinesame as linedefault outputlme.dline("*", 5);
slinesuccesson success outputlme.sline("*");
elineerroron error-ed outputlme.eline("/", 50);
wlinewarningfor warnings like outputlme.wline("*");
hlinehighlightfor highlighting an outputlme.hline("*");

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:

{
	"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 colorsBackground colorsModifiers
blackbgBlackreset
redbgRedbold
greenbgGreendim
yellowbgYellowitalic (not widely supported)
bluebgMagentaunderline
magentabgCyaninverse
cyanbgWhitehidden
whitebgBluestrikethrough (not widely supported)
gray

You can specify multiple styles for a text by mentioning it as an Array. Example:

{
	"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.

Propertieswhat it does?
colors.logs.defaultstyles lme.d()
colors.logs.successstyles lme.s()
colors.logs.errorstyles lme.e()
colors.logs.warningstyles lme.w()
colors.logs.highlightstyles lme.h()
colors.logs.infostyles lme.i()
colors.logs.tracestyles lme.t()

Default configurations

You can find default configurations in

./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:

{
	"colors": {
		"logs": {
			"default": ["white"],
			"success": ["bold", "green"],
			"warning": ["bgYellow", "black"],
			"error": ["bgRed", "white"],
			"highlight": ["bgCyan", "black"],
			"info": ["bold", "cyan"],
			"trace": ["green"]
		}
	}
}



More configurations are on its way.

If you wish to file any feature/bugs, mention it on issues.


Enjoy.

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
Loves lme? tell your friends..

Change log

  • v1.4.1
    • Patch: Excluding an unnecessary folder -> reduces package size.
  • v1.4.0 (26th Jan 2017)
    • Added support for custom color configuration.
    • Added support for multiple arguments. (thanks @demacdonald)
    • Stability and performance improvements.
  • v1.3.1, v1.3.2
    • Docs update.
  • v1.3.0
    • Internal code structure redesigned for better flexibility. (thanks @demacdonald for #4)
    • This package is now capable of having more features in a well structured manner. Developers can now add new features with ease. We invite you to do so.
  • v1.2.0
    • Adds support for trace.
    • Adds support for info. (thanks @amandeepmittal)
    • Bug fixes
      • line() functions now support older versions of node.
      • Changed some colors for better accessibility on Windows and Linux machines.
      • Fixed some minor quirks.
  • v1.1.3
    • bug fixes
    • docs update
  • v1.1.2
    • bug fixes
    • docs update
  • v1.1.1
    • bug fixes
    • docs update
  • v1.1.0
    • adds support for drawing lines
    • docs update
  • versions < 1.1.0
    • adds support for semantic outputs.
    • bug fixes
    • doc updates

License

MIT © Vajahath Ahmed

Keywords

FAQs

Package last updated on 26 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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