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

@avalon-cloud/debugger-ng

v10.0.0

Published

Angular 19 DebuggerNg Library with Layered Architecture

Downloads

9

Readme

DebuggerNg - Angular 分層架構日誌庫

Angular TypeScript MIT License

一個採用分層架構設計的 Angular 日誌庫,提供結構化的日誌記錄和自動批次發送功能。

🏗️ 架構設計

本庫採用分層架構 (Layered Architecture),分為四個清晰的層次:

├── Dto 層          # 資料傳輸物件與類型定義
├── Access 層       # API 呼叫與例外處理
├── Service 層      # 核心業務邏輯
└── Controller 層   # UI 對接介面

📁 檔案結構

src/lib/
├── dto/
│   ├── debugger-log-level.enum.ts    # 日誌層級枚舉
│   ├── debugger-log.dto.ts           # 日誌資料結構
│   └── debugger-config.dto.ts        # 配置資料結構
├── access/
│   └── debugger-ng.api.ts            # API 呼叫服務
├── service/
│   └── debugger-ng.service.ts        # 核心日誌服務
└── controller/
    └── debugger-ng.controller.ts     # 控制器介面

🚀 安裝

npm install debugger-ng

💡 使用方式

1. 在 AppModule 中導入必要模組

import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';

@NgModule({
  imports: [HttpClientModule],
  // ...
})
export class AppModule {}

2. 在元件中使用

import { Component, OnInit } from '@angular/core';
import { DebuggerNgController } from 'debugger-ng';

@Component({
  selector: 'app-root',
  template: '<h1>My App</h1>'
})
export class AppComponent implements OnInit {
  constructor(private debuggerController: DebuggerNgController) {}

  ngOnInit(): void {
    // 初始化設定
    this.debuggerController.init({
      apiEndpoint: 'https://your-api.com/logs',
      appName: 'MyApp',
      environment: 'production',
      enabled: true
    });

    // 記錄日誌
    this.debuggerController.logInfo('應用程式啟動', 'AppComponent');
    this.debuggerController.logWarning('低儲存空間', 'DiskService', { available: '1GB' });
    this.debuggerController.logError('未處理的例外', 'ErrorHandler', { code: 500 });
  }
}

🔧 API 參考

DebuggerNgController

主要的控制器介面,提供以下方法:

init(config: DebuggerConfigDto): void

初始化 debugger 設定

logInfo(message: string, context?: string, metadata?: Record<string, unknown>): void

記錄資訊層級日誌

logWarning(message: string, context?: string, metadata?: Record<string, unknown>): void

記錄警告層級日誌

logError(message: string, context?: string, metadata?: Record<string, unknown>): void

記錄錯誤層級日誌

flushLogs(): void

手動刷新日誌到伺服器

DebuggerConfigDto

interface DebuggerConfigDto {
  apiEndpoint: string;    // API 端點 URL
  appName?: string;       // 應用程式名稱
  environment?: string;   // 環境名稱
  enabled?: boolean;      // 是否啟用
}

DebuggerLogDto

interface DebuggerLogDto {
  level: DebuggerLogLevel;              // 日誌層級
  message: string;                      // 訊息內容
  timestamp: string;                    // 時間戳記
  context?: string;                     // 上下文
  metadata?: Record<string, unknown>;   // 額外資料
}

⚡ 特性

  • 分層架構: 清晰的關注點分離
  • 自動批次發送: 每30秒自動發送日誌到伺服器
  • 例外處理: Access 層統一處理 API 呼叫例外
  • TypeScript 支援: 完整的型別定義
  • Angular 19 相容: 支援最新的 Angular 版本
  • 本地端日誌: 同步輸出到瀏覽器 console

🛠️ 開發

# 安裝依賴
npm install

# 建置庫
npm run build

# 執行測試
npm test

# 執行 lint
npm run lint

📄 License

MIT License

🤝 貢獻

歡迎提交 Issue 和 Pull Request!