Skip to content

sarojsahu-dev/SdkLogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

SDKLogger ๐Ÿš€

API License

A comprehensive, high-performance logging system designed for Android SDKs and applications. Enterprise-grade logging with analytics, multiple destinations, and production-ready features.

โœจ Key Features

  • ๐ŸŽฏ Multi-SDK Support - Track logs from different SDKs separately
  • ๐Ÿ“Š Rich Analytics - Real-time insights and health monitoring
  • ๐Ÿš€ High Performance - Async logging with coroutines
  • ๐Ÿ“ Multiple Destinations - Console, File, Custom (Network, Database)
  • ๐Ÿ”ง Production Ready - File rotation, error handling, resource management

๐Ÿ“ฆ Installation

Step 1: Add JitPack Repository

Add to your root settings.gradle:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

Step 2: Add Dependency

Add to your module's build.gradle:

dependencies {
    implementation 'com.github.sarojsahu-dev:SdkLogger:0.0.1'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
}

Step 3: Permissions (For File Logging)

Add to AndroidManifest.xml:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

๐Ÿš€ Quick Start

Basic Usage (2 minutes setup)

class MySDK {
    // Simple logger setup
    private val logger = SDKLogger.getInstance("MySDK", "1.0.0")
    
    fun performOperation() {
        logger.info("Operation", "Started")
        
        try {
            // Your code here
            logger.info("Operation", "Success")
        } catch (e: Exception) {
            logger.error("Operation", "Failed", e)
        }
    }
}

With Metadata (Rich logging)

logger.info("Payment", "Processing payment",
    metadata = mapOf(
        "transactionId" to "txn_12345",
        "amount" to 99.99,
        "currency" to "USD"
    )
)

โš™๏ธ Configuration Options

Console Only (Default)

val logger = SDKLogger.getInstance("MySDK", "1.0.0")
// Ready to use - logs to Android Logcat

Console + File Logging

val config = SDKLoggerConfig.Builder()
    .addDestination(ConsoleDestination())
    .addDestination(FileDestination(
        logDirectory = File(context.getExternalFilesDir(null), "logs"),
        maxFileSize = 10 * 1024 * 1024L, // 10MB
        maxFiles = 5
    ))
    .build()

val logger = SDKLogger.getInstance("MySDK", "1.0.0", config)

Production Ready

val config = SDKLoggerConfig.Builder()
    .setEnabled(BuildConfig.DEBUG) // Only in debug builds
    .setMinLogLevel(LogLevel.INFO)
    .setAsync(true) // High performance
    .build()

๐Ÿ”ง Configuration Options

SDKLoggerConfig.Builder Options

Method Description Default
setEnabled(Boolean) Enable/disable logging true
setMinLogLevel(LogLevel) Minimum log level to process VERBOSE
addDestination(LogDestination) Add log destination ConsoleDestination()
setFormatter(LogFormatter) Set log formatter DefaultLogFormatter()
addInterceptor(LogInterceptor) Add log interceptor None
setMetadataCollection(Boolean) Enable metadata collection true
setStackTrace(Boolean) Enable stack trace capture true
setBufferSize(Int) Set async buffer size 100
setFlushInterval(Long) Set flush interval (ms) 5000
setAsync(Boolean) Enable async processing true
setMaxLogFileSize(Long) Max log file size (bytes) 10MB
setMaxLogFiles(Int) Max number of log files 5

FileDestination Options

Parameter Description Default
logDirectory Directory for log files Required
baseFileName Base name for log files "sdk_logs"
maxFileSize Maximum file size before rotation 10MB
maxFiles Maximum number of files to keep 5
formatter Log formatter to use DefaultLogFormatter()
FileDestination(
    logDirectory = File(context.filesDir, "my_logs"),
    baseFileName = "app_logs",
    maxFileSize = 5 * 1024 * 1024L, // 5MB
    maxFiles = 3,
    formatter = JsonLogFormatter() // or DefaultLogFormatter()
)

๐Ÿ” How to View Logs

Android Studio Logcat

  1. Open Logcat tab
  2. Filter by your SDK name (e.g., "MySDK")
  3. See logs in real-time

Log Files

  • Location: /Android/data/com.yourapp/files/logs/
  • Format: app_logs.log, app_logs.1.log, etc.
  • Rotation: Automatic when size limit reached

๐Ÿ“Š Log Analytics (Health Monitoring)

val analytics = LogAnalytics()

// Get insights
val stats = analytics.getStatistics()
val totalLogs = stats["totalLogs"] // Total log count
val errorRate = calculateErrorRate(stats) // Error percentage
val topSDKs = stats["logCountsBySDK"] // Most active SDKs

// Health check
when {
    errorRate > 0.1 -> "๐Ÿ”ด CRITICAL" 
    errorRate > 0.05 -> "๐ŸŸก WARNING"
    else -> "๐ŸŸข HEALTHY"
}

๐Ÿ“š Documentation

For detailed implementation guides and advanced features:

๐Ÿ’ก Examples

๐Ÿค Contributing

We welcome contributions! Here's how you can help make SDKLogger better:

๐Ÿš€ Quick Start for Contributors

  1. Fork the repository
  2. Clone your fork: git clone https://github.com/sarojsahu-dev/SdkLogger.git
  3. Create a feature branch: git checkout -b feature/amazing-feature
  4. Make your changes
  5. Test thoroughly
  6. Commit with clear messages: git commit -m 'Add amazing feature'
  7. Push to your branch: git push origin feature/amazing-feature
  8. Create a Pull Request

๐Ÿ’ก How to Contribute

  • ๐Ÿ› Bug Reports - Found a bug? Open an issue
  • โœจ Feature Requests - Have an idea? Start a discussion
  • ๐Ÿ“– Documentation - Improve docs, add examples, fix typos
  • ๐Ÿงช Testing - Add tests, improve coverage
  • ๐Ÿ’ป Code - Fix bugs, add features, optimize performance

๐Ÿ“‹ Development Guidelines

  • Follow Kotlin coding standards
  • Add tests for new features
  • Update documentation for changes
  • Ensure backward compatibility
  • Keep performance in mind

๐Ÿ—๏ธ Areas We Need Help

  • Custom Destinations (Database, Network, Cloud)
  • Advanced Analytics features
  • Performance Optimizations
  • Documentation improvements
  • Example Projects and tutorials

๐Ÿ—บ๏ธ Roadmap & Future Plans

๐Ÿ”ฎ Upcoming Features

v0.1.0 - Enhanced Analytics (Next Release)

  • ๐Ÿ“Š Real-time Dashboard - Web-based logging dashboard
  • ๐Ÿ“ˆ Advanced Metrics - Performance insights and trends
  • ๐Ÿ”” Smart Alerts - Intelligent error detection
  • ๐Ÿ“ฑ Mobile Dashboard - In-app log viewer

v0.2.0 - Cloud Integration

  • โ˜๏ธ Cloud Destinations - Firebase, AWS CloudWatch, Azure
  • ๐ŸŒ Remote Configuration - Dynamic logging config
  • ๐Ÿ”„ Log Streaming - Real-time log streaming
  • ๐Ÿ“ค Bulk Upload - Efficient cloud synchronization

v0.3.0 - Advanced Features

  • ๐Ÿค– AI-Powered Insights - Automatic issue detection
  • ๐Ÿ” Log Search & Query - Powerful search capabilities
  • ๐Ÿ“Š Custom Visualizations - Charts and graphs
  • ๐ŸŽฏ Predictive Analytics - Trend prediction

๐Ÿ’ก Future Innovations

  • ๐ŸŒŸ LogQL Support - Query language for logs
  • ๐Ÿ” End-to-End Encryption - Advanced security
  • ๐Ÿ“ฑ Cross-Platform - iOS and Flutter support
  • ๐Ÿงฉ Plugin Marketplace - Community plugins
  • ๐Ÿ“‹ Compliance Tools - GDPR, HIPAA automation

๐ŸŽฏ Vision

Create the most comprehensive and developer-friendly logging solution for mobile applications, with enterprise-grade features accessible to developers of all levels.


๐ŸŒŸ Community & Feedback

Join our growing community of developers:

  • ๐Ÿ› Issues - Report bugs, request features
  • ๐Ÿ“ง Email - Direct feedback and suggestions
  • โญ Star this repo if SDKLogger helps your project!

About

A comprehensive, high-performance logging system designed for Android SDKs and applications. Enterprise-grade logging with analytics, multiple destinations, and production-ready features.

Resources

License

Stars

7 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages