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

@blastorg/srcds-log-parser

v2.1.0

Published

Log parser for Source Dedicated Server

Downloads

25

Readme

srcds-log-parser

build & release package downloads

A log parsing tool, that can be used for parsing logs sent from CS2 game server via an HTTP endpoint.

Big shout out to the original author of this library negezor, who created this awesome library which strongly types log events coming from the game server.

Reasoning behind the fork of this library

The reason why we have created this fork of the library, is because we saw that the library hasn't been actively worked on for about 2 years.

We have changed this library up a bit after Valve, the creators of Counter Strike, released their version 2 of the game (Counter Strike 2). They changed up some formats of how they are outputting the logs from the game server, and this library is up-to-date on that format.

What's the difference between this library and the original one?

We have chosen to remove the log receiver because we didn't see a use case for it, the main part of this library should be as the name implies srcds-log-parser

We have added a few things which update the parser to be able to parse the new CS2 logs. The other part which has changed is the format the steam id is returned in. In the logs, the steam id includes the steam universe, which the steam account is connected to. To give developers and users who uses this library a better experience, we have chosen to convert the steam id coming from the logs to steam id 64 (decimal) format, which can be stored as a BigInt, because of it's size.

Requirements

In order to install and use this package, you need to have Node.js installed (at least v18).

Because this library is using regex for all of it's parsing, it does not need any other dependencies.

Installation

$ npm install @blastorg/srcds-log-parser

Example usage

import { parse } from '@blastorg/srcds-log-parser';

// Log coming from CS2 game server
const log = '10/20/2020 - 10:30:50: "AttackerName<93><[U:1:230970467]><CT>" [698 2222 -69] killed "VictimName<94><[U:1:230970467]><TERRORIST>" [1303 2143 64] with "hkp2000" (throughsmoke headshot)'

const parsedLog = parse(log);

console.log(parsedLog);
{
  type: "killed",
  receivedAt: Date("10/20/2020 10:30:50");
  payload: {
    attacker: {
      kind: "player",
      entityId: 93,
      steamId: "76561198191236195", // Steam ID 64 (BigInt)
      name: "AttackerName",
      position: [698, 2222, -69],
      team: {
        id: 3,
        name: "COUNTER_TERRORISTS",
      },
    },
    victim: {
      kind: "player",
      entityId: 94,
      steamId: "76561198191236195", // Steam ID 64 (BigInt)
      name: "VictimName",
      position: [1303, 2143, 64],
      team: {
        id: 2,
        name: "TERRORISTS",
      },
    },
    weaponName: "hkp2000",
    modifiers: ["throughsmoke", "headshot"],
  },
}