FileLogger

class FileLogger(context: Context, filePath: String = context.filesDir.path, fileName: String = DEFAULT_FILE_NAME, format: FileFormat = FileFormat.Logcat) : ILogger

A file-based logger that writes log messages to a specified file asynchronously. This logger supports different file format. Each entry is formatted with a timestamp, log level, and tag.

Parameters

context

The context used to access the file directory and creating LogcatLogger instance.

filePath

The directory path where the log file will be created or exists.

fileName

The name of the file to write logs to. Defaults to DEFAULT_FILE_NAME.

format

The format in which logs will be written. Defaults to FileFormat.Logcat.

Constructors

Link copied to clipboard
constructor(context: Context, filePath: String = context.filesDir.path, fileName: String = DEFAULT_FILE_NAME, format: FileFormat = FileFormat.Logcat)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun log(level: Level, tag: String, message: String)

Logs a message with the specified level, tag, and message by writing it to a log file. The actual logging operation is delegated to a specific logger implementation based on the format specified for this FileLogger. The logging operation is performed asynchronously to avoid blocking the caller's thread.