logg

Guide for using @guiiai/logg — a lightweight structured logger for Node.js and browser. Use this skill whenever the user imports from '@guiiai/logg', mentions logg, needs structured logging with JSON or pretty output, wants caller-aware logs with clickable hyperlinks, needs child loggers with persistent fields, or asks about lightweight alternatives to winston, pino, or bunyan. Also use when setting up application logging with log levels, custom formatters, or error extraction.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "logg" with this command: npx skills add guiiai/logg/guiiai-logg-logg

@guiiai/logg

Lightweight structured logger for Node.js and browser with stack parsing, caller records, and clickable hyperlinks.

Quick Start

import { initLogger, useGlobalLogger } from '@guiiai/logg'

// Initialize with defaults (Verbose level, Pretty format)
initLogger()

const log = useGlobalLogger('MyApp')
log.log('Hello world!')

Core API

Creating Loggers

import { createLogg, createLogger, createGlobalLogger } from '@guiiai/logg'

// Named context
const log = createLogg('http/request').useGlobalConfig()

// Auto-context from call site (includes file:line clickable hyperlinks)
const log = createLogger().useGlobalConfig()

// Auto-context + auto global config
const log = createGlobalLogger()

Aliases: useLogg = createLogg, useLogger = createLogger, useGlobalLogger = createGlobalLogger

Log Levels

import { LogLevel, setGlobalLogLevel, setGlobalLogLevelString } from '@guiiai/logg'

setGlobalLogLevel(LogLevel.Debug)
// or
setGlobalLogLevelString('debug')
LevelValueDescription
Error0Only errors
Warning1Errors + warnings
Log2+ general logs
Verbose3+ verbose info
Debug4Everything

Output Formats

import { Format, setGlobalFormat } from '@guiiai/logg'

setGlobalFormat(Format.Pretty) // Colored human-readable output
setGlobalFormat(Format.JSON)   // Structured JSON for production

JSON output:

{"level":"log","context":"app","timestamp":"2024-01-01T00:00:00.000Z","message":"User logged in","fields":{"userId":"123"}}

Pretty output:

[2024-01-01 00:00:00] LOG app: User logged in { userId: '123' }

Structured Fields

// Single field (fluent chaining)
log
  .withField('requestId', req.id)
  .withField('url', req.url)
  .error('Resource not found (404)')

// Multiple fields at once
log
  .withFields({ userId: '12345', ip: '192.168.1.1' })
  .log('User logged in')

Child Loggers

Child loggers inherit parent config and carry persistent fields:

const parentLog = createLogg('app').useGlobalConfig()

const childLog = parentLog.child({
  module: 'database',
  version: '1.0.0',
})

childLog.log('Connected') // includes module + version fields automatically

Error Handling

try {
  // ...
} catch (err) {
  // Automatically extracts message, stack trace, and cause
  log.withError(err).error('Operation failed')

  // Or inline
  log.errorWithError('Failed to process request', err)
}

Custom Processors

// Custom time format
const log = createLogg('app')
  .useGlobalConfig()
  .withTimeFormatter(date => date.toLocaleString('en-US', { timeZone: 'America/New_York' }))

// Custom error processor
const log = createLogg('app')
  .useGlobalConfig()
  .withErrorProcessor(err => {
    if (err instanceof CustomError) return { ...err, customField: 'value' }
    return err
  })

Configuration Methods (Fluent API)

All return a new logger instance (immutable):

MethodDescription
.useGlobalConfig()Apply global level/format settings
.child(fields)Create child with persistent fields
.withContext(ctx)Set context string
.withLogLevel(level)Set log level
.withFormat(format)Set output format
.withField(key, value)Add single field
.withFields(obj)Add multiple fields
.withError(err)Attach error object
.withTimeFormatter(fn)Custom timestamp format
.withErrorProcessor(fn)Custom error transform

Typical Setup Pattern

import { Format, initLogger, LogLevel, useGlobalLogger } from '@guiiai/logg'

// Once at app entry
initLogger(
  process.env.NODE_ENV === 'production' ? LogLevel.Log : LogLevel.Debug,
  process.env.NODE_ENV === 'production' ? Format.JSON : Format.Pretty,
)

// In each module
const log = useGlobalLogger('module-name')
log.log('ready')

Key Rules

  1. Call initLogger() or setGlobalLogLevel() + setGlobalFormat() once at app startup
  2. Use .useGlobalConfig() on logger instances to pick up global settings
  3. withField / withFields / child return new instances — they don't mutate
  4. Use Format.JSON in production, Format.Pretty in development
  5. Works in both Node.js and browser — format auto-adapts

Documentation

For the latest API reference, use context7 to query @guiiai/logg documentation.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

HTML to Markdown

Convert HTML↔Markdown for web clipping, clean notes, and batch content migration. Use when users ask 网页转Markdown/Markdown转HTML/批量转换. Supports local files, UR...

Registry SourceRecently Updated
Coding

Podfetcher Tools

Search podcasts, browse episodes, and fetch podcast transcripts from Podfetcher using the bundled Node.js CLI, SDK, or MCP server.

Registry SourceRecently Updated
Coding

test

Extract and categorize expenses from receipts or statements, map to GL codes, check compliance with policies, and flag anomalies for review.

Registry SourceRecently Updated
Coding

CEO Master

Transforms the agent into a strategic CEO and orchestrator. Vision, decision-making, resource allocation, team dispatch, scaling playbook from €0 to €1B. Use...

Registry SourceRecently Updated