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

@ganache/console.log

v0.4.2

Published

A Solidity library and EVM hooks for using console.log from Solidity contracts

Downloads

4,510

Readme

@ganache/console.log

A Solidity library and EVM hooks for using console.log from Solidity contracts.

Usage:

@ganache/console.log was designed to be used with the @ethereumjs/vm npm package.

Install @ganache/console.log:

> npm install @ganache/console.log --save-exact

@ganache/console.log has two parts, a console.sol Solidity library file, and a method to capture logs generated by the use of the console.sol library.

console.sol Solidity Library

The console.sol library is available at @ganache/console.log/console.sol. There are various ways to make this file available to your contracts and Solidity build pipelines, so this part is left up to the user.

Use it in Solidity just like any other library, e.g.,

// SPDX-License-Identifier: MIT
pragma solidity >= 0.4.22 <0.9.0;

import "console.sol";

contract MyContract {
    constructor() {
        console.log("got here");
    }
}

console.log parser (maybeGetLogs):

To use @ganache/console.log directly within an instance of the @ethereumjs/vm VM:

import { ConsoleLogs, maybeGetLogs } from "@ganache/console.log";

// ... initialize vm ...

// vm should be an instance of @ethereumjs/vm
vm.evm.events.on("step", event => {
  const logs: ConsoleLogs | null = maybeGetLogs(event); // (string | bigint | boolean)[] | null
  // do something with `logs`
});

Note: Ganache CLI, as well as Ganache.server and Ganache.provider, already implement the logger parser and will automatically log calls to console.sol to standard output just like JavaScript's console.log.