Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

rdhillbb/logging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

3 Commits

Repository files navigation

Logging System

A thread-safe, asynchronous logging system that writes messages to timestamped files.

Installation

import "path/to/logging"

Quick Start

// Initialize with default settings (buffer size: 1000)
InitLogServer()
// Enable logging - creates ./logs directory and log file
if err := EnableLogging(); err != nil {
 log.Fatal(err)
}
// Write logs asynchronously
WriteLogs("Starting application...")
// Check logging status
if IsLoggingEnabled() {
 WriteLogs("System is running")
}
// Disable logging - ensures all messages are written before closing
DisableLogging()

Custom Configuration

// Initialize with custom buffer size
InitLogServer(WithBufferSize(2000))

Features

  • Thread-safe operations
  • Non-blocking writes with configurable buffer
  • Automatic log file creation with timestamps
  • Clean session markers
  • Log files format: ./logs/anthropic-debug-YYYYMMDD-HHMMSS.log

Best Practices

  1. Initialize early in your application
  2. Always handle EnableLogging() errors
  3. Call DisableLogging() before application shutdown
  4. Monitor stderr for dropped message warnings

File Format Example

=== Session Started: 2024年12月09日 15:04:05 ===
[2024年12月09日 15:04:05.123] Log message 1
[2024年12月09日 15:04:06.234] Log message 2
=== Session Ended: 2024年12月09日 15:04:07 ===

About

Thread Safe logging system

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /