Skip to content

Commit

Permalink
📝 Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
v20100v committed Dec 19, 2024
1 parent ab279ab commit 6b4877e
Show file tree
Hide file tree
Showing 14 changed files with 354 additions and 157 deletions.
14 changes: 8 additions & 6 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ site_name: VBA Monologger
site_url: https://github.com/6i-software/vba-monologger/
site_author: 2o1oo <[email protected]>
site_description: >-
VBA Monologger is an advanced and flexible logging solution for VBA (<i>Visual Basic for Applications</i>) ecosystem.
VBA Monologger is an advanced and flexible logging open-source solution for VBA (<i>Visual Basic for Applications</i>) ecosystem.
copyright: Copyright &copy; 2024, 6i-software - 2o1oo

repo_name: 6i-software/vba-monologger
Expand Down Expand Up @@ -145,11 +145,13 @@ nav:
- Install: getting-started/install.md
- Quick start: getting-started/quick-start.md
- Usages:
- "Set the logger's name": getting-started/usages/channel.md
- "Use placeholders": getting-started/usages/placeholders.md
- "Add a custom formatter": getting-started/usages/add-custom-formatter.md
- "Add a pre-processor": getting-started/usages/add-pre-processor.md
- Creating your logger: getting-started/creating-custom-logger.md
- "Identify a logger with a channel": getting-started/usages/channel.md
- "Add context data to log messages": getting-started/usages/add-context-data-to-log-messages.md
- "Add extra data to log messages via a pre-processor": getting-started/usages/add-pre-processor.md
- "Create a custom formatter": getting-started/usages/create-custom-formatter.md
- "Create a custom logger from scratch": getting-started/usages/create-custom-logger.md
- "Create a null logger": getting-started/usages/create-null-logger.md
- "Dependency injection for logging capabilities in a custom class module": getting-started/usages/inject-logger-into-custom-class-module.md
- Under the hood:
- under-the-hood/index.md
- Log severity levels: under-the-hood/log-severity-levels.md
Expand Down
2 changes: 1 addition & 1 deletion docs/overrides/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h1>Log smarter, debug faster in VBA</h1>
Get started
</a>
<a href="{{ 'under-the-hood/' | url }}"
title="To understand and learn what's happening with each compontents of this library"
title="To understand and learn what's happening with each components of this library"
class="md-button">
Learn more
</a>
Expand Down
82 changes: 0 additions & 82 deletions docs/src/getting-started/creating-custom-logger.md

This file was deleted.

11 changes: 4 additions & 7 deletions docs/src/getting-started/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

1. Download the VBA Monologger Excel Add-in (.xlam file) to your computer.

[6i_VBA-Monologger.xlam](https://github.com/6i-software/vba-monologger/raw/refs/heads/main/src/6i_VBA-Monologger.xlam)

<small>*Hash SHA1: 46E0FF01DE2A81254375BCF0B5C9BB97C4E53E35*</small>
[6i_VBA-Monologger.xlam](https://github.com/6i-software/vba-monologger/raw/refs/heads/main/src/6i_VBA-Monologger.xlam)<br/>
<small>*Hash SHA1: 46E0FF01DE2A81254375BCF0B5C9BB97C4E53E35*</small><br/><br/>



2. Put this xlam file into a folder trusted by Excel. Microsoft requires that the xlam file's location be set as a *Trusted Location* for the add-in to function properly. To set this up, go to: *File > Options > Trust Center > Trust Center Settings > Trusted Locations > Add New Location*.
2. Put this xlam file into a folder trusted by Excel. Microsoft requires that the xlam file's location be set as a *Trusted Location* for the add-in to function properly. To set this up, go to: *File > Options > Trust Center > Trust Center Settings > Trusted Locations > Add New Location*.<br/><br/>

3. Make sur the Developper tab is visible in Excel. By default, the Developer Ribbon is hidden; to enable it, go to *File > Options > Customize Ribbon*, then check the *Developer* box under the Main Tabs section and validate it.
<br/>
![excel_developer_tab.png](excel_developer_tab.png)
![excel_developer_tab.png](excel_developer_tab.png)<br/><br/>

4. And finally, add the .xlam file as a reference in your VBA project through *Tools > References* in the VBA editor.
<br/>
Expand Down
54 changes: 26 additions & 28 deletions docs/src/getting-started/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ It indicates the severity of each event, from the most trivial to the most catas

*VBA Monologger* manages 8 standard severity levels **to classify the importance of log messages**, following the [PSR-3](https://www.php-fig.org/psr/psr-3/) standard, which is itself based on [RFC-5424](https://www.rfc-editor.org/rfc/rfc5424), the standard defined by the IETF (*Internet Engineering Task Force*) to specify the format of messages for the Syslog protocol, which is used for transmitting logs over IP networks.

| Log level | Description |
|-------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `EMERGENCY` | Indicates a very critical situation that requires immediate attention. (System crash, data corruption) |
| `ALERT` | Signals an alert condition. (Critical disk space running out) |
| `CRITICAL` | Indicates a serious error. (Database connection failure, server downtime) |
| `ERROR` | Represents an error in the system. (Failed to save user data, unexpected exception) |
| `WARNING` | A warning about a potential problem. (Use a deprecated function used, low memory warning) |
| `NOTICE` | Important notifications that are not urgent. (User login successful, configuration change detected) |
| `INFO` | General information about the normal operation. (System startup, data processed successfully) |
| `DEBUG` | Detailed information for debugging. (Variable values during loop iteration, query execution details). Notes, that the '**debug**' method exposes presents in PSR-3 is rename into '**trace**' in order to be compatible in VBA ecosystem. |
| Log level | Description |
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `EMERGENCY` | Indicates a very critical situation that requires immediate attention. (*system crash, data corruption*) |
| `ALERT` | Signals an alert condition. (*critical disk space running out*) |
| `CRITICAL` | Indicates a serious error. (*database connection failure, server downtime*) |
| `ERROR` | Represents an error in the system. (*failed to save user data, unexpected exception*) |
| `WARNING` | A warning about a potential problem. (*use a deprecated function used, low memory warning*) |
| `NOTICE` | Important notifications that are not urgent. (*user login successful, configuration change detected*) |
| `INFO` | General information about the normal operation. (*system startup, data processed successfully*) |
| `TRACE` | Detailed information for debugging. (*variable values during loop iteration, execution details*). Notes, that the '**debug**' method exposes presents in PSR-3 is rename into '**trace**' in order to be compatible in VBA ecosystem. |



Expand All @@ -79,44 +79,44 @@ The logger is designed to handle multiple logging levels, directing each log ent
```mermaid
mindmap
root((Logger))
Handlers
node1(Handlers)
HandlerConsoleVBA<br>*for all levels*
FormatterLine
HandlerConsole<br>*for all levels*
FormatterANSIColoredLine
FormatterANSIColoredLine
HandlerFile<br>*exclude debug level*
FormatterJSON
HandlerEmail<br>*for level greater than error*
FormatterHTML
Processors
node2(Processors)
ProcessorPlaceholders
ProcessorUID
Name of loger, a.k.a. log channel
node3(Name of loger, a.k.a. log channel)
```

Additionally, the logger standardizes and simplifies the use of logging methods (such as methods: `logger.trace`, `logger.info`, ...). It offers a consistent and intuitive approach to logging at different levels of severity, letting developers effortlessly call the appropriate logging level without dealing with the underlying technical details. Each log level can be invoked through a simple, clear method, making logging an integral yet unobtrusive part of the development process.

Every logger must implement the `LoggerInterface`, which provides the following methods:
Every logger implements the `LoggerInterface`, which provides the following methods:

```vbscript
Logger.trace "Authentication function call for user 'Bob Morane'."
Logger.info "User 'UltraVomit' has logged in successfully."
Logger.notice "Process completed successfully with minor issues."
Logger.warning "'Beetlejuice' should not be called more than 3 times."
Logger.error "An error occurred with the user 'DRZCFOS2'."
Logger.critical "System is in an unstable state."
Logger.alert "Action required: unable to generate the dashboard."
Logger.emergency "A critical failure occurred in the application."
Logger.alert "Action required: unable to generate the dashboard."
Logger.critical "System is in an unstable state."
Logger.error "An error occurred with the user 'DRZCFOS2'."
Logger.warning "'Beetlejuice' should not be called more than 3 times."
Logger.notice "Process completed successfully with minor issues."
Logger.info "User 'UltraVomit' has logged in successfully."
Logger.trace "Authentication function call for user 'Bob Morane'."
```


### Identifying a logger with a channel

**A log channel is a powerful way to identify which part of an application a log entry is associated with**. This is especially useful in large applications with multiple components and multiple loggers. The idea is to have several logging systems sharing the same handler, all writing into a single log file. Channels help identify the source of the log, making filtering and searching more manageable.
**A channel is a powerful way to identify which part of an application a log entry is associated with**. This is especially useful in large applications with multiple components and multiple loggers. The idea is to have several logging systems sharing the same handler, all writing into a single log file. Channels help identify the source of the log, making filtering and searching more manageable.

Here’s an example with three distinct logging channels to demonstrate how they help differentiate logs by application component: one channel for the main application (`app`), another for authentication (`auth`), and a third for data processing (`data`).

```
``` title='Logging system with multiples loggers identified by channels'
[2024-11-05 09:15:34] auth.INFO: User login successful
[2024-11-05 09:16:01] app.INFO: Dashboard loaded successfully
[2024-11-05 09:16:20] data.DEBUG: Data import started
Expand Down Expand Up @@ -225,7 +225,7 @@ In addition to the basic log message, you may sometimes want to include extra in

Whether it's the `context` option or the `extra` option, they are essentially VBA dictionaries, where you can store key-value pairs that hold relevant information. When you create a log entry, this context can be attached and will be incorporated into the log output, providing deeper insights into the logged event. This feature is a great way to enrich your log entries with important details and provide better traceability and understanding of your application's behavior.

```vbscript
```vbscript title='Using placeholders with data context'
' Set context
Dim context As Object: Set context = CreateObject("Scripting.Dictionary")
context.Add "Username", "v20100v"
Expand All @@ -239,9 +239,7 @@ Logger.info "Adding the new user: '{username}'", context
Logger.info "Adding the new user: '{username}'", context, extra
```

Result:

```
``` title='Result'
[2024-11-05 09:15:34] app.INFO: Adding a new user | {"Username": "v20100v"}
[2024-11-05 09:15:34] app.INFO: Adding the new user: 'v20100v' | {"Username": "v20100v"}
[2024-11-05 09:15:34] app.INFO: Adding the new user: 'v20100v' | {"Username": "v20100v"} | extra: {"CPU-Usage":"51%"}
Expand Down
5 changes: 2 additions & 3 deletions docs/src/getting-started/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ So to instantiate your first logger that output logs into the VBA console, just

```vbscript
Public Sub howto_use_logger_console_VBA()
' Instantiate the logger with the factory
Dim Logger As VBAMonologger.LoggerInterface
Set Logger = VBAMonologger.Factory.createLoggerConsoleVBA()

Expand Down Expand Up @@ -36,10 +35,10 @@ This logger, provided by the factory's method `createLoggerConsoleVBA`, is confi

As you can see, in the signature of this factory's method, it is possible to set the name the logger (channel) and to load a custom formatter.

```vbscript
```vbscript title='VBAMonologger.Factroy.createLoggerConsoleVBA()'
Public Function createLoggerConsoleVBA( _
Optional ByVal paramLoggerName As String = vbNullString, _
Optional ByRef paramFormatter As VBAMonologger.FormatterInterface = Nothing _
Optional ByRef paramFormatter As FormatterInterface = Nothing _
) As VBAMonologger.Logger
```

Expand Down
Loading

0 comments on commit 6b4877e

Please sign in to comment.