From 11b5ad158ae4f8c0e81dada21858fd635a5c6beb Mon Sep 17 00:00:00 2001 From: able Date: Sat, 18 Nov 2023 01:22:21 -0600 Subject: [PATCH] Post probably --- IDLs and BlogIDL; Part One.md | 70 +++++++++++++++++++++++++++++++++++ README.md | 12 +++--- 2 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 IDLs and BlogIDL; Part One.md diff --git a/IDLs and BlogIDL; Part One.md b/IDLs and BlogIDL; Part One.md new file mode 100644 index 0000000..31bbedc --- /dev/null +++ b/IDLs and BlogIDL; Part One.md @@ -0,0 +1,70 @@ +You might have noticed the language used in my blog post is not any other existing language. + +It is what is called an IDL or Interface Definition Language. +Typically IDLs are used to define interchange formats for programs, like I use it for. + +These languages are used to define how data is laid out in byte format. + +In this post I will be explaining and defining a log format. + +Typical logging systems have multiple severities of logs. + +The [log](https://docs.rs/log/latest/log) crate for rust operates using five different log levels +``` + Error + Warn + Info + Debug + Trace +``` + +The [winston](https://www.npmjs.com/package/winston) library for javascript uses the following levels. +``` + error + warn + info + http + verbose + debug + silly +``` + + +There is also [this](https://datatracker.ietf.org/doc/html/rfc5424) RFC which I won't read + + + + + + + + +I am partial to the `log` method so let us adopt that format for log levels. +We should also assign a numerical value to each log level starting with the most important to the least important. +```rust +enum LogLevel { + Error = 0, + Warn = 1, + Info = 2, + Debug = 3, + Trace = 4, +} +``` +Thats a bit much and adding a new level is not an automatic increment thing. + +Lets introduce a new concept to the language called an attribute. +```rust +@auto_increment +enum LogLevel { + Error = 0, + Warn, + Info, + Debug, + Trace, +} +``` +The `auto_increment` attribute finds all enum variants with a number and increments by one whole number until it finds an already assigned number or there are no more variants. + +This reduces the chance of messing up aswell as makes you just type less. +Syntax sugar and all that. + diff --git a/README.md b/README.md index 79c82da..a2caf24 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,11 @@ ˈbaɪbəl - ## In order - [Unix and mice](Unix;%20Your%20Mouse%20are%20a%20file.md) +## In order +[Unix and mice](Unix;%20Your%20Mouse%20are%20a%20file.md) - [Files???](Files;%20an%20overview.md) +[Files???](Files;%20an%20overview.md) - [Driver Dependencies](Catch-22;%20an%20overview.md) +[Driver Dependencies](Catch-22;%20an%20overview.md) - [Storing Hell in my heart](ATA,%20NVMe,%20SATA,%20Floppy%20Disks%20and%20Optical%20Drives;%20Storing%20my%20own%20personal%20hell.md) - - \ No newline at end of file +[Storing Hell in my heart](ATA,%20NVMe,%20SATA,%20Floppy%20Disks%20and%20Optical%20Drives;%20Storing%20my%20own%20personal%20hell.md)