Skip to content

Commit

Permalink
DT-19: stenographer from r logger rename (#3)
Browse files Browse the repository at this point in the history
* Renaming.

* Rnamed package.

* Version bump.

* Run tests.

* Update docs.

* More unit tests.

* Tests.

* Docs.

* Better docs.

* Mistake.

* Mispelled package name.

* Fixed demos and tests.

* Project files.

* CRAN level workflow.

* Coverage and formatting.

* Ignore and licence fix.

* Better R CMD check.

* Better code cov.

* Better R CMD check.

* Fix licence and news md file.

* Dev stuff.

* Don't ignore dev code.

* Better badges.

* Don't need citation thing if in description already.

* Fix CRAN checks.

* Fix readme.

* Ignore HTML files.

* Ignore HTML files.

* Fixing imports.

* Fix imports.

* Fix imports.

* Fix build.

* Rebuild.

* Merge will bump to 1.0.0 for CRAN release.
  • Loading branch information
dereckmezquita authored Jan 13, 2025
1 parent 4845a96 commit c36c550
Show file tree
Hide file tree
Showing 44 changed files with 1,554 additions and 1,535 deletions.
11 changes: 11 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,14 @@ TODO.md
dev-docs/
dev/
research/
.*\.sqlite$

^BUILD\.sh$
^CONTRIBUTING\.md$
^DEV\.md$
^LICENSE\.md$
^pkgdown/
^run-tests\.R$
^scripts/

^README\.html$
83 changes: 83 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: R-CMD-check

on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: '0 0 * * 0' # Run every Sunday at midnight UTC

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (R-${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: macOS-latest, r: 'devel'}
- {os: ubuntu-latest, r: '4.1.0'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel'}
- {os: windows-latest, r: 'release'}
- {os: windows-latest, r: 'devel'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}

- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y texlive-latex-base texlive-latex-recommended texlive-fonts-recommended texlive-fonts-extra
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install --cask basictex
sudo /Library/TeX/texbin/tlmgr update --self
sudo /Library/TeX/texbin/tlmgr install inconsolata
echo "/Library/TeX/texbin" >> $GITHUB_PATH
# EUREKA this windows set up worked!
- name: Install system dependencies (Windows)
if: runner.os == 'Windows'
run: |
choco install miktex --params="/FileTypeAssociations=0" -y
echo "C:\Program Files\MiKTeX\miktex\bin\x64" >> $env:GITHUB_PATH
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
args: c('--as-cran')

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# dev
dev/
temp*
*.ignore.*
*html
Expand Down
33 changes: 30 additions & 3 deletions BUILD.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
#!/usr/bin/env bash
#!/bin/bash

# check online platform: https://win-builder.r-project.org/upload.aspx

# Set script to exit on any errors.
set -e

# Define the package name
PACKAGE_NAME=$(basename $PWD)

# Preliminary step: document the package
echo "Writing documentation..."
Rscript -e "devtools::document()"
Rscript -e "devtools::check()"
Rscript -e "devtools::install()"

# Step 1: Clean previous builds
echo "Cleaning previous builds..."
rm -rf ${PACKAGE_NAME}_*.tar.gz

# Step 2: Build the package
echo "Building the package..."
R CMD build .

# Step 3: Check the package with --as-cran
echo "Checking the package with --as-cran..."
R CMD check --as-cran ${PACKAGE_NAME}_*.tar.gz

# Step 4: Install the package
echo "Installing the package..."
R CMD INSTALL ${PACKAGE_NAME}_*.tar.gz

echo "Build, check, and installation complete!"
17 changes: 2 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to Logger
# Contributing to stenographer

Thank you for your interest in contributing to Logger!
Thank you for your interest in contributing to stenographer!

## Code of Conduct

Expand All @@ -26,19 +26,6 @@ Please read and adhere to our [Code of Conduct](CODE_OF_CONDUCT.md).
- We aim to minimise external dependencies, including tidyverse packages.
- Write clear, efficient, and maintainable code.

Example:

```r
box::use(
Logger[Logger, LogLevel]
)

log_message <- function(message, level = LogLevel$INFO) {
logger <- Logger$new()
logger$log(level, message)
}
```

## Commit Messages

- Use present tense ("Add feature", not "Added feature")
Expand Down
29 changes: 18 additions & 11 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
Package: Logger
Package: stenographer
Type: Package
Title: Flexible and Customisable Logging System for R
Version: 0.0.32
URL: https://github.com/dereckmezquita/R-Logger
Title: Flexible and Customisable Logging System
Version: 0.1.0
URL: https://github.com/dereckmezquita/stenographer
Authors@R:
person(given = "Dereck",
family = "Mezquita",
role = c("aut", "cre"),
email = "dereck@mezquita.io",
comment = c(ORCID = "0000-0002-9307-6762"))
Maintainer: Dereck Mezquita <dereck@mezquita.io>
Description: A flexible logging system for R that supports multiple log levels, custom output functions, and file logging. It provides an R6 class for easy integration into existing projects and supports colored console output.
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.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
VignetteBuilder: knitr
RoxygenNote: 7.3.2
Depends: R (>= 4.1.0)
Depends:
R (>= 4.1.0)
Imports:
R6,
rlang,
jsonlite,
fs,
crayon,
RSQLite,
DBI
Suggests:
testthat (>= 3.0.0),
diffviewer,
knitr,
rmarkdown,
box,
future,
future.apply
future.apply,
RSQLite
VignetteBuilder: knitr
Config/testthat/edition: 3
29 changes: 2 additions & 27 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,27 +1,2 @@
# MIT License with Citation Requirement

Copyright (c) 2024 Dereck Mezquita, Dereck's Projects

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

Additionally, any use of this Software in commercial, academic or research settings
must include appropriate citation. The required citation is:

Mezquita, D. (2024). R-Logger. https://github.com/dereckmezquita/R-Logger.
ORCID: 0000-0002-9307-6762

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
YEAR: 2025
COPYRIGHT HOLDER: Dereck Mezquita
22 changes: 21 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
# Generated by roxygen2: do not edit by hand

export(LogLevel)
export(Logger)
export(Stenographer)
export(collapse)
export(messageParallel)
export(tableToString)
export(valueCoordinates)
importFrom(DBI,dbExecute)
importFrom(DBI,dbExistsTable)
importFrom(DBI,dbWriteTable)
importFrom(R6,R6Class)
importFrom(crayon,blue)
importFrom(crayon,cyan)
importFrom(crayon,magenta)
importFrom(crayon,red)
importFrom(crayon,silver)
importFrom(crayon,white)
importFrom(crayon,yellow)
importFrom(fs,dir_create)
importFrom(fs,dir_exists)
importFrom(fs,file_create)
importFrom(fs,file_exists)
importFrom(fs,path_dir)
importFrom(jsonlite,fromJSON)
importFrom(jsonlite,toJSON)
importFrom(rlang,abort)
importFrom(utils,capture.output)
43 changes: 43 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# stenographer [v1.0.0](https://github.com/dereckmezquita/stenographer/milestone/1) (12 January 2025)

## BREAKING CHANGES

- **N/A**

## NEW FEATURES

1. **Hierarchical Logging Levels:** Implemented multiple logging levels (`ERROR`, `WARNING`, `INFO`, `OFF`) to control message output granularity.
2. **File-Based Logging:** Added support for logging messages to user-specified file paths, enabling persistent log storage.
3. **Database Logging Integration:** Integrated database support using `DBI` and `RSQLite` for efficient and scalable log management.
4. **Contextual Logging:** Introduced contextual logging capabilities to attach metadata to log entries, enhancing traceability.
5. **Customisable Message Formatting:** Enabled custom message formatting functions to tailor log output according to user preferences.
6. **Coloured Console Output:** Incorporated `crayon` for colour-coded console messages, improving readability and distinguishing log levels.
7. **Parallel Processing Support:** Developed the `messageParallel` function to handle message output from parallel processes seamlessly.
8. **Structured Error Reporting:** Implemented JSON formatting for structured error reporting, facilitating easier parsing and analysis of log data.
9. **Comprehensive Documentation:** Created detailed vignettes and function documentation to guide users through package features and usage scenarios.

## IMPROVEMENTS

1. **Enhanced Package Structure:** Optimized the internal organization of the package for better maintainability and scalability.
2. **Robust Error Handling:** Improved error handling mechanisms to provide more informative and consistent error messages across the package.
3. **Performance Optimization:** Streamlined logging operations to minimize performance overhead, ensuring efficient execution even in high-throughput environments.
4. **Refined R6 Class Implementation:** Strengthened the `Stenographer` R6 class for more reliable and flexible logging functionality.
5. **Dependency Management:** Managed package dependencies effectively, ensuring that all required packages are correctly specified and utilized within the package codebase.

## DOCUMENTATION

1. **Detailed Vignettes:** Developed comprehensive vignettes demonstrating various use cases, configuration options, and best practices for using the `stenographer` package.
2. **Enhanced Function Documentation:** Expanded function documentation with extensive examples and clearer explanations to assist users in understanding and utilizing package functions effectively.
3. **Comprehensive README:** Updated the `README.md` with installation instructions, feature overviews, and quick start guides to provide users with a clear entry point to the package.

## DEVELOPMENT

1. **Continuous Integration Setup:** Established GitHub Actions workflows for automated testing, coverage reporting, and package checks to ensure code quality and reliability.
2. **Comprehensive Test Suite:** Implemented a robust test suite using `testthat` to validate package functionality and prevent regressions.
3. **CRAN Policy Compliance:** Ensured that the package adheres to CRAN submission policies, facilitating smooth package release and maintenance.
4. **Dependency Management:** Managed package dependencies effectively, ensuring that all required packages are correctly specified and utilized within the package codebase.

## NOTES

1. **First Official Release:** This is the inaugural release of the `stenographer` package, marking its availability for CRAN submission and general use.
2. **R Version Compatibility:** The package is compatible with R versions 4.1.0 and above, ensuring broad usability across different R environments.
Loading

0 comments on commit c36c550

Please sign in to comment.