console-service
Manage angular console logging with environment-aware gating and custom service wrappers.
Install
mkdir -p .claude/skills/console-service && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15820" && unzip -o skill.zip -d .claude/skills/console-service && rm skill.zipInstalls to .claude/skills/console-service
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
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.Key capabilities
- →Add console logging to Angular files
- →Use `contextConsole` for scoped logging
- →Apply `always`, `never`, or `opts()` for per-call overrides
- →Utilize timers, groups, table, dir, assert, or count methods
- →Understand console visibility rules for dev vs prod
- →Implement message prefix conventions for logs
How it works
The skill patches `ConsoleService` over the native `console` in `App.ngOnInit()`, gating all `console.*` calls based on `ConsoleService.enabled` and per-call overrides.
Inputs & outputs
When to use console-service
- →Add production-safe console logs
- →Configure console gating
- →Use custom log wrappers
- →Debug console visibility
About this skill
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, oropts() - Using timers (
time/timeEnd/timeLog), groups,table,dir,assert, orcount - 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
alwaysonly for operational messages (errors, disconnects) — not data-bearing payloads. - Audit any call site that logs HTTP responses or form values before using
always.
When not to use it
- →When logging auth tokens, passwords, API keys, or user PII
- →When `always` is used for data-bearing payloads
- →When logging HTTP responses or form values without auditing
Limitations
- →It is specific to an Angular project's `ConsoleService` implementation
- →It requires `patchConsole()` to be called in `App.ngOnInit()`
- →It has strict security rules against logging sensitive information
How it compares
This skill provides an environment-aware console wrapper that gates log visibility, offering fine-grained control over console output unlike direct use of the native `console` object.
Compared to similar skills
console-service side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| console-service (this skill) | 0 | 3mo | No flags | Beginner |
| angular | 100 | 4mo | Review | Advanced |
| angular-best-practices | 21 | 3mo | No flags | Advanced |
| create-signal-store | 0 | 1mo | No flags | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
angular
sickn33
Modern Angular (v20+) expert with deep knowledge of Signals, Standalone Components, Zoneless applications, SSR/Hydration, and reactive patterns. Use PROACTIVELY for Angular development, component architecture, state management, performance optimization, and migration to modern patterns.
angular-best-practices
sickn33
Angular performance optimization and best practices guide. Use when writing, reviewing, or refactoring Angular code for optimal performance, bundle size, and rendering efficiency.
create-signal-store
FabianGosebrink
Use when the user asks to add state management or create a store for a feature in this Angular workspace.
bullmq-specialist
davila7
BullMQ expert for Redis-backed job queues, background processing, and reliable async execution in Node.js/TypeScript applications. Use when: bullmq, bull queue, redis queue, background job, job queue.
azure-monitor-opentelemetry-ts
microsoft
Instrument applications with Azure Monitor and OpenTelemetry for JavaScript (@azure/monitor-opentelemetry). Use when adding distributed tracing, metrics, and logs to Node.js applications with Application Insights.
idmp
ha0z1
Use when you need to deduplicate concurrent or repeated async calls, prevent duplicate API requests, cache async function results, add automatic retry with exponential backoff, memoize heavy computation wrapped in Promise, replace SWR/Provider for request sharing, invalidate cache with flush, or per