oh-my-log
Beautiful console logs for your console applications with string substitution using
fürmat
& styling with Chalk.
Install
npm install --only=production --save oh-my-log
API
myLog(name, [options])
- name (
String
, Required): The name/label to use - options (
Object
, Optional): An optionaloptions
object may be passed that alters certain behaviours
Returns: Function
The logging function
const logger = const log =
The above example will output:
-
Create custom local variables:
const log =// outputs: `Hi, my name is ahmad. repeat, my name is ahmad` -
Supports creating custom modifiers:
const log =// outputs `FOO` -
Use chained Chalk styles as modifiers:
const log = -
Combine for extra magic:
const log =// outputs a colored version of: `Hi, my name is ahmad. repeat, my name is ahmad`
Options
Name | Type | Required | Description | Default |
---|---|---|---|---|
prefix |
String |
✖️ |
prefix this string after substitution with locals values using fürmat |
[%name] %date: |
locals |
Object |
✖️ |
locals object, see fürmat for details |
false |
modifiers |
Object |
✖️ |
custom modifiers, see fürmat for details |
{} |
chalk |
Boolean |
✖️ |
enable/disable chalk modifiers support see fürmat for details |
true |
date |
String |
✖️ |
any dateformat compatible value |
hh:MM:ss TT |
func |
Function |
✖️ |
The logging function | console.log |
fürmat
& Chalk
oh-my-log
relies heavily on fürmat
for styling text (using chalk
) and adding modifiers functions for extended formating, please review fürmat
and chalk
documentation for more details on how to use those modules.
oh-my-log
will also look for options
object in your package.json
file. This is accomplished using pkg-config
, refer to pkg-config
's README for more info
©️ ahmadnassri.com · License: ISC · Github: @ahmadnassri · Twitter: @ahmadnassri