Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xxmacmillanxx/vlog
A simple V module for logging capabilities.
https://github.com/xxmacmillanxx/vlog
vlang vlang-module vlang-package
Last synced: about 15 hours ago
JSON representation
A simple V module for logging capabilities.
- Host: GitHub
- URL: https://github.com/xxmacmillanxx/vlog
- Owner: xXMacMillanXx
- Created: 2023-09-30T20:13:19.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-09T22:46:14.000Z (about 1 year ago)
- Last Synced: 2023-10-09T23:32:05.359Z (about 1 year ago)
- Topics: vlang, vlang-module, vlang-package
- Language: V
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# vlog
IMPORTANT!
This module is currently depricated, since I found out that V has its own log module.
I still might continue working on this module for practice, but probably not to release it as a finished module.
If you are looking for a V log module, just use `import log`.vlog is a module for the V language. It provides simple to use logging capabilities.
You can specify a severity for your log entries and decide which of those should be logged.
Log entries can be output on the terminal, a log file or both. Currently, everytime the program runs, a new log file gets created, there is no functionality to reuse the same log file, yet.# Usage
```v
module mainimport vlog
mut logger := vlog.Logger.new()
x := 5
logger.log(vlog.Severity.debug, 'Value of x: ${x}')
```Severity provides debug, normal, warning and error, so you can specify if an entry is a debug message, information, a warning (e.g., a reconnect to a server) or an error (e.g., information why the program stopped).
You can specify with the 'logger' which severities should be logger, so if you need less logs / information you could only log entries with severity warning and error.```v
module mainimport vlog
mut logger := vlog.Logger.new()
logger.track_severities(.warning | .error)x := 5
logger.log(.debug, 'Value of x: ${x}') // not logged
logger.log(.warning, 'This will be logged')
```To write to a log file you can use the following.
```v
module mainimport vlog
mut logger := vlog.Logger.new()
logger.set_file_path('./logs/')!
logger.set_terminal_output(false)logger.log(.normal, 'Gets logged to a file, but not to the terminal output.')
```