PrintLib 1.2.0

The ultimative printling libary for Rust
Documentation

PrintLib

PrintLib is a libary for rust which makes printing easy.

Install

To add PrintLib to your project, go into your project folder and execute:

cargo add PrintLib

Then you can import PrintLib just like other crates:

use PrintLib::*;

Documentation

This is the official documentation for the PrintLib.

Error

The module PrintLib::Error is the module with which you can build error messages.

The ErrorFactory class

Function name Parmaters Description
new ecode: String, msg: String This is the initializer of the class. It creates a new ErrorFactory with the error-code ecode and the error message msg
add_code_line line: String, display_line_no: bool, line_no: usize, display_add: bool This function adds a new line to the error message. The parameter line is the code line of which the error message is specified. display_lin_no means if the line number (parameter line_no is the line number) is shown. display_add means if a +++ needs to be shown (it is good for showing potential fixes).
add_where</code where_start: usize, where_length: usize, where_msg_b: bool, where_msg: String This function adds an string to the error message to show where the error is. where_start means where the showing should start (e.g. where_start = 3 means it starts after the 3rd character). where_length means how long the showing should be. where_msg_b: when true it showes a string to the right of the showing. When false it shows just the showing. where_msg is the msg right to the showing (if where_msg_b is true)
add_arrow file: String, line: usize, where_start: usize Add adds an arrow in the format -->{file}:{line}:{where_start} to the error message
add_arrowW file: String, line: usize, Add adds an arrow in the format -->{file}:{line} to the error message
print Prints the error message

Logger

The module PrintLib::Logger is the module with which you can use the logger.

The Logger Class

Function name Parmaters Description
new Is the initializer of the class. Returns a new Instance
debug msg: String Prints the message msg in level debug
info msg: String Prints the message msg in level info
warn msg: String Prints the message msg in level warning
error msg: String Prints the message msg in level error