Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(log): document FileHandler #6175

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

efekrskl
Copy link
Contributor

@efekrskl efekrskl commented Nov 5, 2024

Documents FileHandler for #3764

@efekrskl efekrskl requested a review from kt3k as a code owner November 5, 2024 21:31
@github-actions github-actions bot added the log label Nov 5, 2024
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.52%. Comparing base (d57a66c) to head (d41d472).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6175   +/-   ##
=======================================
  Coverage   96.51%   96.52%           
=======================================
  Files         538      538           
  Lines       41276    41302   +26     
  Branches     6162     6162           
=======================================
+ Hits        39837    39865   +28     
+ Misses       1395     1393    -2     
  Partials       44       44           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +66 to 156
/** Opened file to append logs to.
* @example Usage
* ```ts no-assert
* import { FileHandler } from "@std/log/file-handler";
*
* const handler = new FileHandler("INFO", { filename: "./logs.txt" });
* handler.setup();
* handler.log('Hello, world!'); // Buffers the message, or writes it to the file depending on buffer state
* handler.flush(); // Manually flushes the buffer
* handler.destroy(); // Closes the file and removes listeners
* ```
* **/
[fileSymbol]: Deno.FsFile | undefined;
/** Buffer used to write to file.
* @example Usage
* ```ts no-assert
* import { FileHandler } from "@std/log/file-handler";
*
* const handler = new FileHandler("INFO", { filename: "./logs.txt" });
* handler.setup();
* handler.log('Hello, world!'); // Buffers the message, or writes it to the file depending on buffer state
* handler.flush(); // Manually flushes the buffer
* handler.destroy(); // Closes the file and removes listeners
* ```
* **/
[bufSymbol]: Uint8Array;
/** Current position for pointer.
* @example Usage
* ```ts no-assert
* import { FileHandler } from "@std/log/file-handler";
*
* const handler = new FileHandler("INFO", { filename: "./logs.txt" });
* handler.setup();
* handler.log('Hello, world!'); // Buffers the message, or writes it to the file depending on buffer state
* handler.flush(); // Manually flushes the buffer
* handler.destroy(); // Closes the file and removes listeners
* ```
* **/
[pointerSymbol] = 0;
/** Filename associated with the file being logged.
* @example Usage
* ```ts no-assert
* import { FileHandler } from "@std/log/file-handler";
*
* const handler = new FileHandler("INFO", { filename: "./logs.txt" });
* handler.setup();
* handler.log('Hello, world!'); // Buffers the message, or writes it to the file depending on buffer state
* handler.flush(); // Manually flushes the buffer
* handler.destroy(); // Closes the file and removes listeners
* ```
* **/
[filenameSymbol]: string;
/** Current log mode.
* @example Usage
* ```ts no-assert
* import { FileHandler } from "@std/log/file-handler";
*
* const handler = new FileHandler("INFO", { filename: "./logs.txt" });
* handler.setup();
* handler.log('Hello, world!'); // Buffers the message, or writes it to the file depending on buffer state
* handler.flush(); // Manually flushes the buffer
* handler.destroy(); // Closes the file and removes listeners
* ```
* **/
[modeSymbol]: LogMode;
/** File open options.
* @example Usage
* ```ts no-assert
* import { FileHandler } from "@std/log/file-handler";
*
* const handler = new FileHandler("INFO", { filename: "./logs.txt" });
* handler.setup();
* handler.log('Hello, world!'); // Buffers the message, or writes it to the file depending on buffer state
* handler.flush(); // Manually flushes the buffer
* handler.destroy(); // Closes the file and removes listeners
* ```
* **/
[openOptionsSymbol]: Deno.OpenOptions;
/** Text encoder.
* @example Usage
* ```ts no-assert
* import { FileHandler } from "@std/log/file-handler";
*
* const handler = new FileHandler("INFO", { filename: "./logs.txt" });
* handler.setup();
* handler.log('Hello, world!'); // Buffers the message, or writes it to the file depending on buffer state
* handler.flush(); // Manually flushes the buffer
* handler.destroy(); // Closes the file and removes listeners
* ```
* **/
[encoderSymbol]: TextEncoder = new TextEncoder();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these symbols should probably be private properties, but since they are not, linting requires them to be documented still. I'm not sure how to handle this better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant