1.0.8 • Published 5 years ago

minimalist-logger v1.0.8

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

Minimalist-logger(https://npmjs.com/package/minimalist-logger)

Definition

This module helps to identify where the call has started and control the log message.

Custom USEFUL log function to string messages

To TEXT(string) messages, we have 5 methods

.l (Log) Multi-line, colored(header: default, body: yellow) .e (Error) Multi-line, colored(header: default, body: red) .u (Unstyled) Multi-line, non-colored .s (SingleLine) Single-line, colored(header: default, body: yellow) .i (Inline) Single-line, non-colored

Both of them have bellow parameters.

The only diference between them are the color of message.

.@param message The message will appear .@param docName (optional) The file name who calls the function .@param functionName (optional) The function name who calls the function .@param line (optional) The line of the call. Take care about edit code and change the line. .@param limit (optional) The amount of char of the message to display .@param startat (optional) The initial startpoint of the message. Useful when comes filtered string.

To OBJECT(any) stream messages, we have 2 methods

.o (Object) Multi-line, colored(header: default, body: yellow) .w (Wrecked) Multi-line, colored(header: default, body: red) .p (Pure) Multi-line, non-colored

Both of o, w and p have bellow parameters. The only diference between them are the color of message.

Obs.: They call the identification header and to show the object, call standard console.log(), but chage the color

.@param message The object stream (system converted) message will appear .@param document (optional) The file name who calls the function .@param functionName (optional) The function name who calls the function .@param line (optional) The line of the call. Take care about edit code and change the line.

Installation

Just put npm i minimalist-logger on your favorite (and available) command application

Usage

When do You need to identify the local of current call, defines this: If You want, take bellow code and put in any JS empty file and run it.

var minLog = require('minimalist-logger');

/* The standard easy way to create a log call. Produces:
4.
5. [NAME_OF_THIS_DOCUMENT] >>> .L(11):
6. This is some message
7. [(IF INDEX.JS, E.G:) Index] >>> .E(12):
8. This is some message
9.
*/
minLog.l('This is some message');
minLog.e('This is some message');


/* Allow You to modify the line number and document name. Produces:
16.
17. >>> File.L(4):
18. This is some message
19. >>> File.ERROR(4)
20. This is some message
21.
*/
minLog.l('This is another some message', 'file', '', 4);
minLog.error('This is another some message', 'file', null, 4);


/* Limit the message length. Produces:
28.
29. [NAME_OF_THIS_DOCUMENT] >>> .LOG(35):
30. Too many messag...
31. [(IF INDEX.JS, E.G:) Index] >>> .E(36):
32. Too many messages to e...
33.
*/
minLog.log('Too many messages to explain this', '', null, null, 15);
minLog.e('Too many messages to explain this', null, '', null, 22);


/* Cut part of start message and limit its length, while modify the caller(function) name. Produces:
40.
41. >>> File_sys.Logger(9):
42. s.io: This is a too big m...
43. >>> File_sys.Logger(9):
44. This is a too big message...
45.
*/
minLog.l('Sys.io: This is a too big message just [for fun, ops...] for explain that we can take just what we need', 'file_sys', 'logger', 9, 25, 2);
minLog.e('Sys.io: This is a too big message just [for fun, ops...] for explain that we can take just what we need', 'file_sys', 'logger', 9, 25, 8);


/* Print full object (if possible). Produces:
53.
54. >>> File.O(62):
55. {"name": "Don","lastname": "johe"}
56. >>> WreckedFile.WRECKED(63):
57. {"name": "Don","lastname": "johe"}
58. [NO COLORS HERE] >>> PureFile.PURE(64):
59. [NO COLORS HERE] {"name": "Don","lastname": "johe"}
60.
*/
minLog.o(JSON.stringify({ "name": "Don", "lastname": "johe" }), 'file');
minLog.wrecked(JSON.stringify({ "name": "Don", "lastname": "johe" }), 'wreckedFile');
minLog.pure(JSON.stringify({ "name": "Don", "lastname": "johe" }), 'PureFile')


/* Print the log in a single-line and multi-line, without colors. Produces:
69.
70. >>> DocumentJson.I(78): [NO COLORS HERE] One text for no one ask for it
71. >>> DocumentJson.INLINE(79): [NO COLORS HERE] One text for no one ask for it
72. >>> DocumentJson.U(80):
73. [NO COLORS HERE] One text for no one ask for it
74. >>> DocumentJson.UNSTYLED(81):
75. [NO COLORS HERE] One text for no one ask for it
76.
*/
minLog.i('One text for no one ask for it');
minLog.inline('One text for no one ask for it');
minLog.u('One text for no one ask for it');
minLog.unstyled('One text for no one ask for it');

Note on version 1.0.0

The first release was a base concept to reduce to useful log.

Note on version 1.0.1

Add the readme(myself -) and follow corrections:

  • Header document format
  • Bug fixes

Note on version 1.0.2, 1.0.3, 1.0.4

Edited the readme file

Note 1.0.5

  • Fixed Header assembly (removing the last char)

Note 1.0.6

Hey, dudes. In this version, was implemented:

  • Auto-identification line (if none was defined on logger method)
  • Message header now containing name file and method { File.Method }
  • Bug fixes

Note 1.0.7

Dudes... Sorry for that, but, if You update to this version, the structure caller has changed. Don't stay anger with Me. Really sorry. But I do this changes to make once more easy to create and control the logger.

What's new here, not more than the bills:

  • Auto-identification file caller (You still can customize the document name)
  • Function structure, now accepting just the message
  • Fix auto-identification line to Linux/Unix systems
  • Bug fixes

Note 1.0.8

Lads... Today, one more update that:

  • Adition of S(Single-line) colorful logger of one-line
  • Adition of I(Inline) non-colorful logger of one-line
  • Adition of U(Unstyled) non-colorful logger of multi-line
  • Adition of P(Pure) non-colorful object logger of multi-line
  • Adition of ALL methods by its full names

    • l or log
    • e or error
    • s or singleLine
    • i or inline
    • u or unstyled
    • o or object
    • w or wrecked
    • p or pure
  • Make more clear the header of log

  • Optmize the custom features of command colors and attributes
  • General optimizations
  • Bug fixes
1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago