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 🙏

© 2026 – Pkg Stats / Ryan Hefner

strayl-logging

v0.2.0

Published

TypeScript/JavaScript SDK for sending logs to Strayl Cortyx

Readme

Strayl Logging SDK для TypeScript/JavaScript

Минималистичный TypeScript/JavaScript SDK для отправки логов в Strayl Cortyx через API ключи.

Установка

npm install strayl-logging

Или с использованием yarn:

yarn add strayl-logging

Или с использованием pnpm:

pnpm add strayl-logging

Быстрый старт

import { StraylLogger } from 'strayl-logging';

// Инициализация логгера
const logger = new StraylLogger({ apiKey: "st_ваш_ключ" });

// Отправка логов
logger.info("Server started", { port: 8000 });
logger.warn("High memory usage", { usage: "85%" });
logger.error("Database connection failed", { retry: true });
logger.debug("Processing request", { request_id: "abc123" });

Получение API ключа

  1. Зарегистрируйтесь на strayl.dev
  2. Перейдите в Dashboard
  3. Откройте вкладку API
  4. Создайте новый API ключ
  5. Скопируйте ключ (формат st_...)

Использование

Базовое использование

import { StraylLogger } from 'strayl-logging';

const logger = new StraylLogger({ apiKey: "st_ваш_ключ" });
logger.info("Application started");

С контекстом по умолчанию

const logger = new StraylLogger({
  apiKey: "st_ваш_ключ",
  defaultContext: {
    service: "my-service",
    version: "1.0.0",
    environment: "production",
  },
});

logger.info("User logged in", { user_id: 123 });
// Отправит: { service: "my-service", version: "1.0.0", environment: "production", user_id: 123 }

Синхронный режим

По умолчанию логи отправляются асинхронно. Для синхронной отправки:

const logger = new StraylLogger({
  apiKey: "st_ваш_ключ",
  asyncMode: false, // Синхронная отправка
});

Кастомный эндпоинт

const logger = new StraylLogger({
  apiKey: "st_ваш_ключ",
  endpoint: "https://custom-endpoint.com/log",
});

Настройка таймаута

const logger = new StraylLogger({
  apiKey: "st_ваш_ключ",
  timeout: 5000, // 5 секунд (по умолчанию 3000)
});

Отключение локального вывода

По умолчанию логи выводятся локально через console и отправляются на сервер. Чтобы отключить локальный вывод:

const logger = new StraylLogger({
  apiKey: "st_ваш_ключ",
  localOutput: false, // Только отправка на сервер, без локального вывода
});

API Reference

StraylLogger

Параметры конструктора

interface StraylLoggerOptions {
  apiKey: string;              // API ключ для аутентификации (обязательный, формат st_...)
  endpoint?: string;            // URL эндпоинта (по умолчанию используется production endpoint)
  defaultContext?: LogContext;  // Контекст по умолчанию для всех логов
  timeout?: number;             // Таймаут запроса в миллисекундах (по умолчанию 3000)
  asyncMode?: boolean;          // Асинхронная отправка (по умолчанию true)
  localOutput?: boolean;        // Локальный вывод логов через console (по умолчанию true)
}

Методы

  • info(message: string, context?: LogContext) - Отправка информационного лога
  • warn(message: string, context?: LogContext) - Отправка предупреждения
  • error(message: string, context?: LogContext) - Отправка ошибки
  • debug(message: string, context?: LogContext) - Отправка отладочного лога
  • log(level: LogLevel, message: string, context?: LogContext) - Отправка лога с указанным уровнем

Типы

type LogLevel = "info" | "warn" | "error" | "debug";
type LogContext = Record<string, any>;

Безопасность

  • API ключи передаются через заголовок Authorization: Bearer <api_key>
  • Все запросы выполняются по HTTPS
  • Ошибки отправки не ломают приложение (проглатываются молча)
  • Логи не содержат чувствительных данных (пароли, токены и т.д.)

Особенности

  • Двойной вывод: Логи выводятся локально (через console) и отправляются на сервер
  • Неблокирующий: По умолчанию логи отправляются асинхронно
  • Безопасный: Ошибки отправки не ломают приложение
  • Минималистичный: Один класс, простой API
  • Типизированный: Полная поддержка TypeScript с типами

Примеры использования

В Node.js приложении

import { StraylLogger } from 'strayl-logging';

const logger = new StraylLogger({
  apiKey: process.env.STRAYL_API_KEY!,
  defaultContext: { service: "web-app" },
});

logger.info("Server started");

В браузерном приложении

import { StraylLogger } from 'strayl-logging';

const logger = new StraylLogger({ apiKey: "st_ваш_ключ" });

// В обработчике события
button.addEventListener('click', () => {
  logger.info("Button clicked", { buttonId: "submit" });
});

В фоновой задаче

import { StraylLogger } from 'strayl-logging';

const logger = new StraylLogger({ apiKey: "st_ваш_ключ" });

async function processTask(taskId: string) {
  try {
    logger.info("Task started", { task_id: taskId });
    // ... обработка задачи ...
    logger.info("Task completed", { task_id: taskId });
  } catch (error) {
    logger.error("Task failed", { 
      task_id: taskId, 
      error: error instanceof Error ? error.message : String(error) 
    });
  }
}

Требования

  • Node.js >= 14.0.0
  • TypeScript >= 5.0.0 (для разработки)

Лицензия

MIT

Поддержка

Разработка

# Клонировать репозиторий
git clone https://github.com/AlemzhanJ/strayl-sdk-py.git
cd strayl-sdk-py/typescript

# Установить зависимости
npm install

# Собрать проект
npm run build