npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hardlog

v4.0.4

Published

A NodeJS library for logging to the console and keeping a hard record of whatever is logged to the console. Forget console.log(), forever!

Downloads

10

Readme

HardLog

A NodeJS library for logging to the console and keeping a hard record of whatever is logged to the console. Forget console.log(), forever!

Installation

Use the following command to install HardLog via NPM:

npm i hardlog --save

Usage

Follow this syntax while using hardlog:

var logs = require('hardlog');

// logs.init() must be used before any other hardlog method
logs.init("Your Name", "Version Number of your software");

// write hardlog code below
logs.write("Write anything to hardlog here!")

Console Output:

hardLog v3.0.0 initialized. Created by Ray Voice and Anna Voice!
	    Follow them: @RayShortHead @AnnaShortHead --2021-06-17T00:25:05.361Z
Write anything to hardlog here! --2021-06-17T00:25:05.362Z

./LogFile.txt Output:

hardLog v3.0.0 initialized. Created by Ray Voice and Anna Voice!
	    Follow them: @RayShortHead @AnnaShortHead --2021-06-17T00:25:05.361Z
Write anything to hardlog here! --2021-06-17T00:25:05.362Z
  1. .write(logString1, logString2, ...): Used to logs something to both the hardlog file and to the stdout console.

  2. .shadow(logString1, logString2, ...): Used to log something to the hardlog file only, no console output.

  3. .log(logString1, logString2, ...): Same as console.log(), but chainable.

  4. .generalLogsDir = logsDir: to change the default logs storage directory to logsDir. (Not chainable)

  5. .generalLogFile = logFile: to change the default logs file to logFile. (Not chainable)

  6. .logFileExists(fileURL): to check if the logs file exists.

  7. .logsHash(): to get the sha256-hex hash of the entire logs file.

  8. .closeLogs(): to close-off the logs file, writing a hash of the logs file it the very last line. If someone tempers with the logs file, this adds a layer of protection to it. This method is (Not chainable) on purpose.

  9. .value: to get the value of the chainable method. (Not chainable itself)

  10. .setValue: to set the internal Value of hardlog. The setting of value can be done with hardlog.value = "something", but using .setValue allows chains.

  11. Comming Soon: Verify hash, alter-chrome integration, etc.

Example

Most methods in hardlog are either "chainable" or "terminal". Hence we can write the code in a chain unless we use a "terminal" prop or method.

var logs = require('hardlog');
logs.init("Ray Voice", "1.0.3");

logs
  .write("First HardLog")
  .shadow("Write anything to hardlog here, without Terminal dispay!")
  .closeLogs(); // Must write this at the very last hardlog

Tips

  1. Use the chalk library to color strings and then pass them to hardlog.
  2. HardLogs are time-stamped.
  3. Avoid using console.log, instead use hardlog.log().
  4. Don't pass more than a single argument to hardlog.write() or hardlog.shadow().
  5. Use .closeLogs() for an added layer of security, in case someone tampers with the log file.

LICENSE

MIT License

Copyright (c) 2021 Ray Voice

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.