Skip to content

Commit

Permalink
DT-19: final adjustments for CRAN release. (#4)
Browse files Browse the repository at this point in the history
* DT-19: final adjustments for CRAN release.

* DT-19: version bump.

* Fix description?

* Simple description.

* Bug reports.

* Simple description.

* Need to quote.

* Need to quote.
  • Loading branch information
dereckmezquita authored Jan 16, 2025
1 parent c36c550 commit e3b6471
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
19 changes: 7 additions & 12 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
Package: stenographer
Type: Package
Title: Flexible and Customisable Logging System
Version: 0.1.0
Version: 1.0.0
URL: https://github.com/dereckmezquita/stenographer
Authors@R:
BugReports: https://github.com/dereckmezquita/stenographer/issues
Authors@R:
person(given = "Dereck",
family = "Mezquita",
role = c("aut", "cre"),
email = "dereck@mezquita.io",
comment = c(ORCID = "0000-0002-9307-6762"))
Description: A comprehensive logging framework for R applications that provides
hierarchical logging levels, database integration, and contextual logging capabilities.
The package supports SQLite storage for persistent logs, provides colour-coded console
output for better readability, includes parallel processing support, and implements
structured error reporting with JSON formatting. It is designed to help developers
track application behaviour, debug issues, and maintain audit trails in production
environments.
Maintainer: Dereck Mezquita <dereck@mezquita.io>
Description: A comprehensive logging framework for R applications that provides hierarchical logging levels, database integration, and contextual logging capabilities. The package supports 'SQLite' storage for persistent logs, provides colour-coded console output for better readability, includes parallel processing support, and implements structured error reporting with 'JSON' formatting.
License: MIT + file LICENSE
Encoding: UTF-8
VignetteBuilder: knitr
RoxygenNote: 7.3.2
Depends:
R (>= 4.1.0)
Depends: R (>= 4.1.0)
Imports:
R6,
rlang,
Expand All @@ -37,5 +33,4 @@ Suggests:
future,
future.apply,
RSQLite
VignetteBuilder: knitr
Config/testthat/edition: 3
6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ You can install stenographer from [www.github.com/dereckmezquita/stenographer](h

```{r, eval = FALSE}
# install.packages("remotes")
remotes::install_github("derecksprojects/stenographer")
remotes::install_github("dereckmezquita/stenographer")
```

## Basic Usage
Expand Down Expand Up @@ -214,11 +214,11 @@ future::plan(future::sequential)

## Contributing

Contributions to stenographer are welcome! Please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) file for guidelines.
Contributions to stenographer are welcome! Please refer to the [CONTRIBUTING.md](https://github.com/dereckmezquita/stenographer/blob/master/CONTRIBUTING.md) file for guidelines.

## License

stenographer is released under the MIT License. See the [LICENSE](LICENSE) file for details.
This package is licensed under the MIT License.

## Citation

Expand Down
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ with:

``` r
# install.packages("remotes")
remotes::install_github("derecksprojects/stenographer")
remotes::install_github("dereckmezquita/stenographer")
```

## Basic Usage
Expand All @@ -55,11 +55,11 @@ steno <- Stenographer$new()

# Log some messages
steno$info("This is an informational message")
#> 2025-01-12T20:03:39.811Z INFO This is an informational message
#> 2025-01-13T13:55:15.524Z INFO This is an informational message
steno$warn("This is a warning")
#> 2025-01-12T20:03:39.813Z WARNING This is a warning
#> 2025-01-13T13:55:15.526Z WARNING This is a warning
steno$error("This is an error")
#> 2025-01-12T20:03:39.835Z ERROR This is an error
#> 2025-01-13T13:55:15.549Z ERROR This is an error
```

## Features
Expand All @@ -80,9 +80,9 @@ custom_steno <- Stenographer$new(

custom_steno$info("This won't be logged")
custom_steno$warn("This will be logged to console and file")
#> 2025-01-12T20:03:39.935Z WARNING This will be logged to console and file
#> 2025-01-13T13:55:15.650Z WARNING This will be logged to console and file
custom_steno$error("This is an error message", error = "Some error")
#> 2025-01-12T20:03:39.936Z ERROR This is an error message
#> 2025-01-13T13:55:15.651Z ERROR This is an error message
#> Error:
#> "Some error"
```
Expand All @@ -91,8 +91,8 @@ Logs are written to the specified file as JSON objects:

``` r
cat(readLines(log_file), sep = "\n")
#> {"datetime":"2025-01-12T20:03:39.935Z","level":"WARNING","msg":"This will be logged to console and file","data":{},"error":{},"context":{}}
#> {"datetime":"2025-01-12T20:03:39.936Z","level":"ERROR","msg":"This is an error message","data":{},"error":"[\"Some error\"]","context":{}}
#> {"datetime":"2025-01-13T13:55:15.650Z","level":"WARNING","msg":"This will be logged to console and file","data":{},"error":{},"context":{}}
#> {"datetime":"2025-01-13T13:55:15.651Z","level":"ERROR","msg":"This is an error message","data":{},"error":"[\"Some error\"]","context":{}}
```

### Database Logging
Expand All @@ -118,14 +118,14 @@ db_steno <- Stenographer$new(

# Log some messages
db_steno$info("This is logged to the database")
#> 2025-01-12T20:03:40.040Z INFO This is logged to the database
#> 2025-01-13T13:55:15.772Z INFO This is logged to the database
#> Context:
#> {
#> "app_name": "MyApp",
#> "fun": "main"
#> }
db_steno$warn("This is a warning", data = list(code = 101))
#> 2025-01-12T20:03:40.047Z WARNING This is a warning
#> 2025-01-13T13:55:15.778Z WARNING This is a warning
#> Data:
#> {
#> "code": 101
Expand All @@ -136,7 +136,7 @@ db_steno$warn("This is a warning", data = list(code = 101))
#> "fun": "main"
#> }
db_steno$error("An error occurred", error = "Division by zero")
#> 2025-01-12T20:03:40.117Z ERROR An error occurred
#> 2025-01-13T13:55:15.844Z ERROR An error occurred
#> Error:
#> "Division by zero"
#> Context:
Expand All @@ -151,8 +151,12 @@ result <- dbGetQuery(db, query)
print(result)
#> id datetime level context
#> 1 3 2025-01-12T20:03:40.117Z ERROR {"app_name":["MyApp"],"fun":["main"]}
#> 2 6 2025-01-13T13:54:50.711Z ERROR {"app_name":["MyApp"],"fun":["main"]}
#> 3 9 2025-01-13T13:55:15.844Z ERROR {"app_name":["MyApp"],"fun":["main"]}
#> msg data error
#> 1 An error occurred <NA> ["[\\"Division by zero\\"]"]
#> 2 An error occurred <NA> ["[\\"Division by zero\\"]"]
#> 3 An error occurred <NA> ["[\\"Division by zero\\"]"]

# Don't forget to close the database connection when you're done
dbDisconnect(db)
Expand Down Expand Up @@ -185,7 +189,7 @@ if (nrow(na_coords) > 0) {
)
)
}
#> 2025-01-12T20:03:40.134Z WARNING NA values found in the dataset
#> 2025-01-13T13:55:15.858Z WARNING NA values found in the dataset
#> Data:
#> {
#> "na_locations": [
Expand Down Expand Up @@ -239,7 +243,7 @@ process_data <- function(df) {
# Test the function with problematic data
df <- data.frame(a = c(1, 2, 3), b = c(0, 2, 0))
process_data(df)
#> 2025-01-12T20:03:40.161Z ERROR Division by zero occurred
#> 2025-01-13T13:55:15.883Z ERROR Division by zero occurred
#> Data:
#> {
#> "infinite_values": [
Expand All @@ -254,7 +258,7 @@ process_data(df)
#> ],
#> "dataset_preview": " a b\n1 1 0\n2 2 2\n3 3 0"
#> }
#> 2025-01-12T20:03:40.163Z ERROR An error occurred while processing data: Division by zero error
#> 2025-01-13T13:55:15.884Z ERROR An error occurred while processing data: Division by zero error
#> Data:
#> {
#> "dataset_preview": " a b\n1 1 0\n2 2 2\n3 3 0"
Expand Down Expand Up @@ -302,12 +306,12 @@ future::plan(future::sequential)
## Contributing

Contributions to stenographer are welcome! Please refer to the
[CONTRIBUTING.md](CONTRIBUTING.md) file for guidelines.
[CONTRIBUTING.md](https://github.com/dereckmezquita/stenographer/blob/master/CONTRIBUTING.md)
file for guidelines.

## License

stenographer is released under the MIT License. See the
[LICENSE](LICENSE) file for details.
This package is licensed under the MIT License.

## Citation

Expand Down

0 comments on commit e3b6471

Please sign in to comment.