Skip to content

dryfish09/QuickLog

Repository files navigation

QuickLog

A simple, lightweight logging library for Kotlin.

Features

  • 🚀 Simple API - Just call info(), warn(), or error()
  • 📦 Lightweight - Zero dependencies (only Kotlin stdlib)
  • 🎯 Easy to use - No configuration needed
  • 🔧 Pure Kotlin - Written in 100% Kotlin

Installation

Gradle (Kotlin DSL)

Add the dependency to your build.gradle.kts:

dependencies {
    implementation("com.dryfish09:quicklog:1.0.0")
}

Gradle (Groovy DSL)

dependencies {
    implementation 'com.dryfish09:quicklog:1.0.0'
}

Maven

<dependency>
    <groupId>com.dryfish09</groupId>
    <artifactId>quicklog</artifactId>
    <version>1.0.0</version>
</dependency>

Usage

Basic Usage

import com.dryfish09.quicklog.*

fun main() {
    info("Application started successfully")
    warn("Disk space is running low")
    error("Failed to connect to database")
}

Output:

[INFO]: Application started successfully
[WARN]: Disk space is running low
[ERROR]: Failed to connect to database

Real-world Examples

Example 1: Web Application

import com.dryfish09.quicklog.*

class UserService {
    fun createUser(username: String, email: String) {
        info("Creating user: $username")
        
        if (username.isBlank()) {
            warn("Username is empty for email: $email")
            return
        }
        
        try {
            // Save user to database
            saveToDatabase(username, email)
            info("User created successfully: $username")
        } catch (e: Exception) {
            error("Failed to create user $username: ${e.message}")
        }
    }
    
    private fun saveToDatabase(username: String, email: String) {
        // Database logic here
    }
}

Example 2: File Processor

import com.dryfish09.quicklog.*
import java.io.File

class FileProcessor {
    fun processFile(filePath: String) {
        info("Processing file: $filePath")
        
        val file = File(filePath)
        if (!file.exists()) {
            error("File not found: $filePath")
            return
        }
        
        if (!file.canRead()) {
            warn("File exists but cannot be read: $filePath")
            return
        }
        
        try {
            val content = file.readText()
            info("Successfully read ${content.length} characters")
            // Process content...
        } catch (e: Exception) {
            error("Error processing file: ${e.message}")
        }
    }
}

Example 3: API Client

import com.dryfish09.quicklog.*

class ApiClient(private val baseUrl: String) {
    
    fun fetchUser(userId: String): String? {
        info("Fetching user with ID: $userId")
        
        return try {
            val response = makeApiCall("$baseUrl/users/$userId")
            info("Successfully fetched user: $userId")
            response
        } catch (e: Exception) {
            error("API call failed for user $userId: ${e.message}")
            null
        }
    }
    
    private fun makeApiCall(url: String): String {
        // Actual API call logic here
        return "{\"id\": \"123\", \"name\": \"John\"}"
    }
}

API Reference

Functions

Function Description Output Format
info(msg: String) Log an informational message [INFO]: message
warn(msg: String) Log a warning message [WARN]: message
error(msg: String) Log an error message [ERROR]: message

Building from Source

Prerequisites

  • JDK 11 or higher
  • Gradle 8.5+ (or use the provided wrapper)

Build Commands

# Clone the repository
git clone https://github.com/dryfish09/quicklog.git
cd quicklog

# Build the library
./gradlew build

# Run tests
./gradlew test

# Generate JAR file
./gradlew jar

# Publish to Maven Local
./gradlew publishToMavenLocal

Testing

# Run all tests
./gradlew test

# Run specific test class
./gradlew test --tests "com.dryfish09.quicklog.QuickLogTest"

# Run tests with detailed output
./gradlew test --info

Test Coverage

The library includes comprehensive unit tests covering:

  • Normal message logging
  • Empty messages
  • Special characters and Unicode
  • Long messages
  • Concurrent logging
  • Performance (30,000+ logs under 1 second)

Project Structure

quicklog/
├── src/
│   ├── main/
│   │   └── kotlin/com/dryfish09/quicklog/
│   │       └── QuickLog.kt          # Main library code
│   └── test/
│       └── kotlin/com/dryfish09/quicklog/
│           ├── QuickLogTest.kt       # Unit tests
│           └── QuickLogIntegrationTest.kt
├── build.gradle.kts                   # Gradle build file
├── settings.gradle.kts                # Gradle settings
├── gradle.properties                  # Gradle configuration
├── README.md                          # This file
└── LICENSE                            # License file

Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow Kotlin coding conventions
  • Add unit tests for new features
  • Update documentation as needed
  • Ensure all tests pass before submitting PR

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Copyright 2024 dryfish09

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Author

dryfish09

Support

Changelog

Version 1.0.0

  • Initial release
  • Added info(), warn(), error() functions
  • Added comprehensive unit tests
  • Added Gradle build configuration

Roadmap

  • Add log levels (DEBUG, INFO, WARN, ERROR, FATAL)
  • Support custom output destinations (files, network, etc.)
  • Add log formatting options
  • Support structured logging (JSON)
  • Add async logging support
  • Create Android version

Why QuickLog?

  • Simple: No complex configuration, just import and use
  • Fast: Minimal overhead, perfect for logging
  • Kotlin-first: Designed specifically for Kotlin projects
  • Production-ready: Thoroughly tested and stable

Made with ❤️ by dryfish09

About

QuickLog: A simple console Kotlin library that helps you logging easier

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages