All Projects → sidhantpanda → logt

sidhantpanda / logt

Licence: MIT license
🖥️ A colourful logger for the browser

Programming Languages

typescript
32286 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to logt

sprout
Golang logging library supporting log retrieval.
Stars: ✭ 85 (+142.86%)
Mutual labels:  color, log, logger
webpack-log
A logger for the Webpack ecosystem
Stars: ✭ 18 (-48.57%)
Mutual labels:  console, log, logger
log-utils
Basic logging utils: colors, symbols and timestamp.
Stars: ✭ 24 (-31.43%)
Mutual labels:  console, color, log
Loglevelnext
A modern logging library for Node.js that provides log level mapping to the console
Stars: ✭ 33 (-5.71%)
Mutual labels:  console, log, logger
Quicklogger
Library for logging on files, console, memory, email, rest, eventlog, syslog, slack, telegram, redis, logstash, elasticsearch, influxdb, graylog, Sentry, Twilio, ide debug messages and throw events for Delphi/Firemonkey/freepascal/.NET (Windows/Linux/OSX/IOS/Android).
Stars: ✭ 137 (+291.43%)
Mutual labels:  console, log, logger
Signale
Highly configurable logging utility
Stars: ✭ 8,575 (+24400%)
Mutual labels:  console, log, logger
debug.js
Debugger of JavaScript, by JavaScript, for JavaScript
Stars: ✭ 19 (-45.71%)
Mutual labels:  console, log, logger
Go Logger
一个简单而强大的 golang 日志工具包,支持同步和异步输出到 命令行,文件, api 接口,文件支持按文件大小,文件行数,日期切分;A simple and powerful golang logging toolkit that supports synchronous and asynchronous output to the console, file, API interfaces, file support by file size, file line number, date sharding.
Stars: ✭ 152 (+334.29%)
Mutual labels:  console, log, logger
ptkdev-logger
🦒 Beautiful Logger for Node.js: the best alternative to the console.log statement
Stars: ✭ 117 (+234.29%)
Mutual labels:  console, log, logger
log
PSR-3 compatible logger
Stars: ✭ 32 (-8.57%)
Mutual labels:  log, logger
paper-terminal
Print Markdown to a paper in your terminal
Stars: ✭ 33 (-5.71%)
Mutual labels:  console, color
spdlog setup
spdlog setup initialization via file configuration for convenience.
Stars: ✭ 68 (+94.29%)
Mutual labels:  log, logger
Multiplatform-Log
Kotlin Multi Platform Logger, for android an ios : Logcat & print
Stars: ✭ 49 (+40%)
Mutual labels:  log, logger
react-native-log-ios
React Native iOS standalone logger
Stars: ✭ 37 (+5.71%)
Mutual labels:  log, logger
yachalk
🖍️ Terminal string styling done right
Stars: ✭ 131 (+274.29%)
Mutual labels:  console, color
manakin
🐦 Prime colors for your Node.js console — quick & safe.
Stars: ✭ 29 (-17.14%)
Mutual labels:  console, color
guzzle-log-middleware
A Guzzle middleware to log request and responses automatically
Stars: ✭ 61 (+74.29%)
Mutual labels:  log, logger
concolor
Colouring template strings using tags with annotations 🎨
Stars: ✭ 35 (+0%)
Mutual labels:  console, color
console-logging
Better, prettier commandline logging for Python--with colors! 👻
Stars: ✭ 111 (+217.14%)
Mutual labels:  console, color
PoShLog
🔩 PoShLog is PowerShell cross-platform logging module. It allows you to log structured event data into console, file and much more places easily. It's built upon great C# logging library Serilog - https://serilog.net/
Stars: ✭ 108 (+208.57%)
Mutual labels:  log, logger
npm version Dependency Status devDependency Status Build Status Known Vulnerabilities

LogT

🖥️ A colorful logger for the browser

See it in action

Demo - https://sidhantpanda.github.io/logt/dist/

Features

Installation

$ npm i logt -S

Usage

You can use this logger for your frontend projects. You can choose as an ES6 module or directly include the script in HTML.

As an ES6 module

Create a file in your project called logger.js or logger.ts

import LogT from "logt";

const LOG_TAG = "sample tag";
let logger;
if (process.env.NODE_ENV === "production") {
  logger = new LogT("error"); // or logger = new LogT("none");
} else {
  logger = new LogT("silly");
}

// See documentation for `readConsole()` for usage
// uncomment following line if you want to override default console methods
// logger.readConsole();

logger.error(LOG_TAG, new Error("example error"));

export default logger;

Include in HTML

<script src="https://cdn.jsdelivr.net/gh/sidhantpanda/logt/dist/logt.min.js"></script>
<script>
  var LOG_TAG = 'sample tag';
  var logger = createLogger('error');

  // See documentation for `readConsole()` for usage
  // uncomment following line if you want to override default console methods
  // logger.readConsole();

  logger.error(LOG_TAG, new Error('example error'));
</script>

Documentation

Logger initialization

import LogT from "logt";

let logger;
// Available log levels -  -1 | 0 | 1 | 2 | 3 | 4 | 5 | 'none' | 'error' | 'warn' | 'info' | 'verbose' | 'debug' | 'silly';

// noneLogger will print nothing
noneLogger = new LogT(-1); // or
noneLogger = new LogT("none");
// if included via HTML script
noneLogger = createLogger(-1); // or
noneLogger = createLogger("none");

// errorLogger will only error messages
errorLogger = new LogT(0); // or
errorLogger = new LogT("error");
// if included via HTML script
errorLogger = createLogger(0); // or
errorLogger = createLogger("error");

// sillyLogger will print all messages
sillyLogger = new LogT(5); // or
sillyLogger = new LogT("silly");
// if included via HTML script
sillyLogger = createLogger(5); // or
sillyLogger = createLogger("silly");

If any other value is supplied to the constructor, a default value of none is used.

APIs

error(logTag: string, message: any, ...rest: any[])

Parameters
  • logTag - A log tag to identify the message and point to source of the message.
  • message - The error log message
  • ...rest - Any additional arguments to be passed onto console.error

warn(logTag: string, message: any, ...rest: any[])

Parameters
  • logTag - A log tag to identify the message and point to source of the message.
  • message - The warning log message
  • ...rest - Any additional arguments to be passed onto console.warn

info(logTag: string, message: any, ...rest: any[])

Parameters
  • logTag - A log tag to identify the message and point to source of the message.
  • message - The info log message
  • ...rest - Any additional arguments to be passed onto console.info

verbose(logTag: string, message: any, ...rest: any[])

Parameters
  • logTag - A log tag to identify the message and point to source of the message.
  • message - The verbose log message
  • ...rest - Any additional arguments to be passed onto console.log

debug(logTag: string, message: any, ...rest: any[])

Parameters
  • logTag - A log tag to identify the message and point to source of the message.
  • message - The debug log message
  • ...rest - Any additional arguments to be passed onto console.log

silly(logTag: string, message: any, ...rest: any[])

Parameters
  • logTag - A log tag to identify the message and point to source of the message.
  • message - The silly log message
  • ...rest - Any additional arguments to be passed onto console.log

image(logLevel: string | number, url: string)

Parameters
  • logLevel - 0 | 1 | 2 | 3 | 4 | 5 | 'error' | 'warn' | 'info' | 'verbose' | 'debug'
  • url - URL for the image or GIF

getLogLevel(): number

Returns the logger instance's log level in numeric form;

setLogLevel(logLevel: string | number)

Update a logger instance's logLevel dynamically later.

Parameters
  • logLevel - New logLevel for the instance. Values: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 'none' | 'error' | 'warn' | 'info' | 'verbose' | 'debug' | 'silly'

showHidden(logLevel: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 'none' | 'error' | 'warn' | 'info' | 'verbose' | 'debug' | 'silly')

Show log messages hidden by the logger. Only logs equal or above logLevel will be shown.

Parameters
  • logLevel - Log level for which logs are to be shown
Example
const logger = new LogT(0);
logger.warn("TAG", "warning message"); // Will not print anything to console
logger.info("TAG", "info message"); // Will not print anything to console
logger.debug("TAG", "debug message"); // Will not print anything to console
logger.silly("TAG", "silly message"); // Will not print anything to console

logger.showHidden(1); // Will print the warning message
logger.showHidden(2); // Will print the info message
logger.showHidden(5); // Will print the debug as well as silly message

readConsole()

Replace default console.error, console.warn, console.info, console.log implementation with logt logger.

Example
const logger = new LogT(0);
logger.readConsole();

console.error(new Error("test error")); // will be same as logger.error('console', new Error('test error'));
console.warn("warn message"); // will be same as logger.warn('console', 'warn message');
console.log("info message"); // will be same as logger.info('console', 'info message');
console.log("log message"); // will be same as logger.debug('console', 'log message');

Changelog

v1.4.0

v1.2.0

Roadmap

Checkout the project page for details about future development.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].