ConsoleService Usage Guide

VerifiedSafe

Provides implementation guidance for ConsoleService, an environment-aware console wrapper in Angular. Use for adding console logging with contextConsole, always/never overrides, and visibility rules.

Sby Skills Guide Bot
DevelopmentBeginner
8/6/2026
Claude CodeCursorWindsurfCopilotCodex
#console#logging#angular#debugging#scoped-logger

Recommended for

Automated summary

Provides guidance on using the project's ConsoleService wrapper for gated, scoped console logging in Angular applications.

Strengths

  • Enforces a consistent scoped logger pattern via contextConsole with automatic class-name prefixes.
  • Allows fine-grained per-call control with always, never, and opts() overrides.
  • Centralizes visibility rules so dev/prod output can be toggled globally, including third-party console calls.
  • Documents the bootstrap patch process and method coverage.

Limitations

  • Only relevant to Angular projects that have the ConsoleService and bootstrap patch implemented.
  • Requires developers to adopt the custom convention (method-name prefixes) for full benefit.
  • The gating mechanism can obscure native console behavior in environments where enableConsole is not set correctly.
When to use it

Use when adding console logging to Angular files or troubleshooting why log output appears or is suppressed in dev vs prod.

When not to use it

Do not use for non-Angular projects or when you need direct access to the native console without the service's gating and prefixing.

Security analysis

Safe
Quality score96/100

This skill provides guidance on using a console logging wrapper. It contains no executable instructions, no external tools, and includes security best practices like avoiding logging sensitive data.

No concerns found

How this analysis is made

Examples

Add scoped logger to a service
I'm working on an Angular project. Add scoped console logging to UserService using contextConsole from @app/core/services/console/console.service. Prefix each log with the method name and label.
Force an error log in production
Use the ConsoleService skill to make a console.error visible even in production. I need to log a critical failure in my payment service. Show me the exact syntax with the always override.
Debug why a log is silent
My console.log calls are not showing up in the production build. Explain the visibility rules for ConsoleService and how to check whether enableConsole is false or if a never override is suppressing them.

name: console-service description: 'Provides implementation guidance for ConsoleService — the environment-aware console wrapper in this Angular project. Use when adding console logging to any Angular file, using contextConsole, always, never, or opts overrides, checking visibility rules, or understanding how the bootstrap patch gates console output. Keywords: console, logging, ConsoleService, contextConsole, always, never, opts, enableConsole, console.log, console.warn, console.error, suppress, force, scoped logger, console gating, production logging, dev logging.'

ConsoleService — Usage Guide

Location

projects/my-app/src/app/core/services/console/
  console.service.ts   ← service, types, contextConsole, opts/always/never
  console.patch.ts     ← patchConsole() bootstrap helper

Path alias: @app/core/services/console/console.service


When to Use This Skill

  • Adding any console.* call in Angular files
  • Deciding whether to use always, never, or opts()
  • Using timers (time/timeEnd/timeLog), groups, table, dir, assert, or count
  • Understanding why a log is or isn't appearing
  • Checking visibility rules for dev vs prod

How It Works

ConsoleService is patched over the native console once in App.ngOnInit() via patchConsole() from console.patch.ts. After that, all console.* calls in the app (including third-party libraries) are automatically gated by ConsoleService.enabled, which is initialised from environment.enableConsole.

| Environment | enableConsole | Default behaviour | |-------------|-----------------|-------------------| | ng serve (dev) | true | All console output visible | | ng build (prod) | false | All console output silent unless force: true |


Scoped Logger (Recommended Pattern)

Add one line at the top of any file — no injection needed:

import { contextConsole } from '@app/core/services/console/console.service';

const console = contextConsole('ClassName');

Every console.* call in that file is then auto-prefixed: [ClassName] message.

ALWAYS use contextConsole for any new logging in this project.


Per-Call Overrides

Import always or never alongside contextConsole when needed:

import { contextConsole, always, never } from '@app/core/services/console/console.service';

const console = contextConsole('ClassName');

// Force output even in production:
console.error(always, 'Critical failure:', err);   // → [ClassName] Critical failure: ...

// Permanently silence even in dev:
console.log(never, 'Polling tick');                // → silent

// Normal log — gated by enableConsole:
console.log('[methodName] value:', value);         // → [ClassName] [methodName] value: ...

Use opts({ force, suppress }) for custom combinations not covered by always/never.


Message Prefix Convention

When logging inside a method, include the method name as a prefix string:

console.log('[methodName] label:', value);
// Output: [ClassName] [methodName] label: value

Visibility Rules (evaluated in order)

| Rule | Condition | Result | |------|-----------|--------| | 1 | suppress: true (per-call) | Always silent — wins over everything | | 2 | force: true (per-call) | Always output — bypasses global toggle | | 3 | enabled = false | Silent (no override present) | | 4 | enabled = true | Output |

suppress always beats force if both are set.


Available Methods

All methods accept always, never, or opts() as an optional first argument.

| Method | Notes | |--------|-------| | log, warn, error, debug, info, trace | Standard output | | group(label?), groupCollapsed(label?) | Opens a collapsible group | | groupEnd() | Closes current group | | clear() | Clears the console | | count(label?) | Increments named counter | | countReset(label?) | Resets named counter | | time(label?) | Starts named timer | | timeEnd(label?) | Stops timer, logs elapsed | | timeLog(label?, ...data) | Logs current timer value | | assert(condition?, ...data) | Logs error if condition is false | | table(tabularData?, properties?) | Tabular display | | dir(item?, options?) | Interactive object listing |

In contextConsole(), label methods (count, countReset, time, timeEnd, timeLog) automatically prepend the tag to the label.


Quick Reference

| Intent | Syntax | |--------|--------| | Scoped logger (recommended) | const console = contextConsole('ClassName') at top of file | | Normal log | console.log('[method] label:', value) | | Always visible (prod-safe) | console.error(always, '[method] msg:', err) | | Always silent | console.log(never, '[method] msg') | | Group related logs | console.group('[method]'); ... console.groupEnd(); | | Time an operation | console.time('label'); ... console.timeEnd('label'); | | Display object tree | console.dir(obj) | | Display array as table | console.table(arr) | | Runtime enable | this.consoleService.enabled = true | | Runtime disable | this.consoleService.enabled = false |


Security Rules

  • Never log auth tokens, passwords, API keys, or user PII — even behind never (the text still exists in source).
  • Use always only for operational messages (errors, disconnects) — not data-bearing payloads.
  • Audit any call site that logs HTTP responses or form values before using always.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/consoleservice-usage-guide-msh3uusf/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/consoleservice-usage-guide-msh3uusf' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/consoleservice-usage-guide-msh3uusf/download' --output '.skill-downloads/consoleservice-usage-guide-msh3uusf/SKILL.md.part' && mv '.skill-downloads/consoleservice-usage-guide-msh3uusf/SKILL.md.part' '.skill-downloads/consoleservice-usage-guide-msh3uusf/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Original excerpt: Quick Reference
IntentSyntax
Scoped logger (recommended)const console = contextConsole('ClassName') at top of file
Normal logconsole.log('[method] label:', value)
Always visible (prod-safe)console.error(always, '[method] msg:', err)
Always silentconsole.log(never, '[method] msg')
Group related logsconsole.group('[method]'); ... console.groupEnd();
Time an operationconsole.time('label'); ... console.timeEnd('label');
Display object treeconsole.dir(obj)
Display array as tableconsole.table(arr)
Runtime enablethis.consoleService.enabled = true
Runtime disablethis.consoleService.enabled = false

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/consoleservice-usage-guide-msh3uusf/SKILL.md' && test -s '.skill-downloads/consoleservice-usage-guide-msh3uusf/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/console-service' && cp -R '.skill-downloads/consoleservice-usage-guide-msh3uusf' '.claude/skills/console-service'

Cursor
test -f '.skill-downloads/consoleservice-usage-guide-msh3uusf/SKILL.md' && test -s '.skill-downloads/consoleservice-usage-guide-msh3uusf/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/console-service' && cp -R '.skill-downloads/consoleservice-usage-guide-msh3uusf' '.cursor/skills/console-service'

Codex
test -f '.skill-downloads/consoleservice-usage-guide-msh3uusf/SKILL.md' && test -s '.skill-downloads/consoleservice-usage-guide-msh3uusf/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/console-service' && cp -R '.skill-downloads/consoleservice-usage-guide-msh3uusf' '.agents/skills/console-service'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/consoleservice-usage-guide-msh3uusf'

openskills read 'consoleservice-usage-guide-msh3uusf'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/consoleservice-usage-guide-msh3uusf/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills