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

@bitdiver/logadapter

v2.0.12

Published

@bitdiver/logadapter / [Exports](docApi/modules.md)

Downloads

10

Readme

@bitdiver/logadapter / Exports

LogAdapter

The log adapter is used to handle the log calls. All the log events from the steps or the runner will be forwarded to the registered log adapter.

LogAdapterConsole

This logger just logs to the console output. It implements the main logic other log adapter may need.

This LogAdapter is intended to be used as a base class for other adapters.

Konfiguration options

configuration

const opts = {
  logLevel: 'error'                        
  timeFormat: 'yyyy-MM-dd HH:mm:ss.SSS ZZ' 
}
  • The logLevel of the logger. Default is ''error''.

  • The time format used to display times in the log. The format comes from 'https://moment.github.io/luxon/' module.

Methods

logAdapter.log(logMessage) : promise

Format of the logMessage

const logMessage = {
  meta: {                             
    run: {
      start: new Date(),
      id: 'runId',
      name: 'suite name',
    },
    tc: {                             
      countCurrent: tcCountCurrent,
      countAll: tcCountAll,
      id: 'tcId',
      name: 'great tc name',
    },
    step: {                           
      countCurrent: stepCountCurrent,
      countAll: stepCountAll,
      id: 'stepId',
      name: 'great step name',
      typ: 'singel',
    },
  },
  data: { anyKey: 'some value' },     
  logLevel: 'error',                  
}
  • The 'run' section of the meta block is always there. No log without a run. This is filled automatically.

  • If the log comes from a test case or a step also the 'tc' section is provided. This is filled automatically.

  • The 'step' section is only provided if the log was initiated by a step. This is filled automatically.

  • The 'data' section contains the real message data.

  • The logLevel is also set automatically.

LogAdapterMemory

This is a special implementation of a LogAdapter. Its mainly used for testing. If there is a unit test for a step this adapter could be used to collect the created logs to validate them

Format the data is stored

const this.logs = {   
  runId: {            
    logs:[{}, ...]    
    testcases: {}     
  }
}
  • The data is stored under the property 'logs' of the LogAdapter.

  • The data is stored per run by the run Id. Normally there will be only one run at a time.

  • This log stores all the logs directly related to the run.

  • Logs which are related to a test case are stored by the test case instance id under this property.

Format of the test case section

const testcase = {
  logs: []     
  steps: {}    
}
  • This log stores all the logs directly related to the test case.

  • Logs which are related to a step are stored by the step instance id under this property.

Format of the step section

const step = {
  logs: []    
}
  • This log stores all the logs directly related to the step.

LogAdapterFile

Stores the logs into a local file system. It will create one directory per run. Then in the run directory one directory per test case. And again in the test case one directory per step.

Konfiguration options

configuration

const opts = {
  targetDir: 'logs'                        
  timeFormatFileName: 'yyyy-MM-dd_HHmmss'  
}
  • The constructor arguments are the 'targetDir'. All the logs will be stored under this directory. This parameter defaults to ''log''

  • The format used to create the file names.