Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

std/log/mod.ts>FileHandler

The Deno Standard Library
Latest
class FileHandler
extends BaseHandler
Re-export
import { FileHandler } from "https://deno.land/std@0.224.0/log/mod.ts";

This handler will output to a file using an optional mode (default is a, e.g. append). The file will grow indefinitely. It uses a buffer for writing to file. Logs can be manually flushed with fileHandler.flush(). Log messages with a log level greater than error are immediately flushed. Logs are also flushed on process completion.

Behavior of the log modes is as follows:

  • 'a' - Default mode. Appends new log messages to the end of an existing log file, or create a new log file if none exists.
  • 'w' - Upon creation of the handler, any existing log file will be removed and a new one created.
  • 'x' - This will create a new log file and throw an error if one already exists.

This handler requires --allow-write permission on the log file.

Constructors

new
FileHandler(levelName: LevelName, options: FileHandlerOptions)

Properties

protected
_buf: Uint8Array
protected
_encoder: TextEncoder
protected
_file: Deno.FsFile | undefined
protected
_filename: string
protected
_mode: LogMode
protected
_openOptions: Deno.OpenOptions
protected
_pointer: number

Methods

handle(logRecord: LogRecord)
log(msg: string)