Skip to content

Repository files navigation

What is VersaLog.dart?

pub packagepub likespub pointsDartLicenseDiscord

VersaLog is a powerful and flexible logging library for Dart.
It supports everything from simple usage to advanced, highly customizable configurations to meet a wide range of needs.


Feature

Basic Logging

  • Supports standard log levels:
    • INFO, ERROR, WARNING, DEBUG, CRITICAL
  • Colored output for better readability
  • Symbol-based prefixes (e.g. [+], [-], [!])

Multiple Output Formats

Easily switch between different log styles:

  • simple[+] message
  • simple2[TIME] [+] message
  • detailed[TIME][LEVEL] : message
  • file[FILE:LINE][LEVEL] message

Tag System

  • Add custom tags to logs
  • Supports multiple tags (e.g. ["API", "AUTH"])
  • Optional default tags

File & Line Tracking

  • Display caller file name and line number
  • Useful for debugging large projects

Log File Saving

  • Automatically save logs to files
  • Output path: ./log/YYYY-MM-DD.log
  • Select which log levels to save

Auto Cleanup

  • Automatically deletes old log files (default: 7 days)
  • Keeps your log directory clean

Auto Cleanup

  • Disable console output
  • Useful for background services

Exception Handling

  • Automatically captures unhandled exceptions
  • Logs them as CRITICAL

Desktop Notifications

  • Optional desktop alerts for errors and critical logs
  • Uses plyer.notification

Asynchronous Logging

  • Non-blocking log processing using threads and queues
  • Improves performance in high-load environments

Support

Join our Discord server for support, questions, and community discussions:

Discord


Installation

dart pub add versalog_dart

Enum

EnumDescription
detailedLogs including execution time and log levels
fileLogs with filename and line number
simpleSimple and easy-to-read logs
simple2Simple and easy-to-read log format. The timestamp is automatically included.

Options

OptionsDescription
show_fileTrue : Display filename and line number (for simple and detailed modes)
show_tagTrue : Show self.tag if no explicit tag is provided
tagDefault tag to use when show_tag is enabled
enable_allShortcut to enable both show_file and show_tag
noticeTrue : When an error or critical level log is output, a desktop notification (using plyer.notification) will be displayed. The notification includes the log level and message.
all_saveTrue : When an error or critical level log is output, the log will be saved to a file.
save_levelsA list of log levels to save. Defaults to ["INFO", "ERROR", "WARNING", "DEBUG", "CRITICAL"].
silentTrue : Suppress standard output (print)
catch_exceptionsTrue : Automatically catch unhandled exceptions and log them as critical

Tag set

import'package:versalog_dart/versalog_dart.dart';
voidmain() {
// one tagfinal logger1 =VersaLog(
enumMode:"detailed",
tag:"APP",
showTag:true,
);
logger1.info("Application started");
// multiple tagsfinal logger2 =VersaLog(
enumMode:"detailed",
tag: ["API", "AUTH"],
showTag:true,
);
logger2.warning("Token expired");
}

Basic Usage

import'package:versalog_dart/versalog_dart.dart';
voidmain() {
final log =VersaLog();
log.info("Application started");
log.warning("Low memory");
log.error("Unexpected error");
log.debug("Debug info");
log.critical("System failure");
}

About

I created an custom logger.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages