Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1 from onedesign/feature/craft3
Browse files Browse the repository at this point in the history
Feature/craft3
  • Loading branch information
mkornatz authored Jul 20, 2018
2 parents 1547984 + 90e7048 commit 3d42216
Show file tree
Hide file tree
Showing 17 changed files with 3,054 additions and 219 deletions.
1 change: 1 addition & 0 deletions .craftplugin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"pluginName":"onelogger","pluginDescription":"Logging Alternative for Craft CMS 3.x using STDOUT and STDERR","pluginVersion":"2.0.0","pluginAuthorName":"One Design Company","pluginVendorName":"onedesign","pluginAuthorUrl":"https://onedesigncompany.com","pluginAuthorGithub":"onedesign","codeComments":"","pluginComponents":"","consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}
33 changes: 31 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
.DS_Store
# CRAFT ENVIRONMENT
.env.php
.env.sh
.env

# COMPOSER
/vendor

vendor/
# BUILD FILES
/bower_components/*
/node_modules/*
/build/*
/yarn-error.log

# MISC FILES
.cache
.DS_Store
.idea
.project
.settings
*.esproj
*.sublime-workspace
*.sublime-project
*.tmproj
*.tmproject
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
config.codekit3
prepros-6.config
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# onelogger Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 2.0.0 - 2018-07-19
### Added
- Initial release
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2018 One Design Company

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.

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.
35 changes: 0 additions & 35 deletions OneLoggerPlugin.php

This file was deleted.

59 changes: 37 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,31 @@

An alternative logger for Craft CMS, including STDOUT.

Looking for Craft 2 Support? [OneLogger for Craft 2](https://github.com/onedesign/onelogger/tree/v1)

## Why?

This is primarily useful Craft sites hosted on Heroku, which uses STDOUT for logging.

# onelogger plugin for Craft CMS 3.x

Logging Alternative for Craft CMS 3.x using STDOUT and STDERR

![Screenshot](resources/img/plugin-logo.png)

## Requirements

This plugin requires Craft CMS 3.0.0-beta.23 or later.

## Installation

You can install One Logger via Composer or Manually.
To install the plugin, follow these instructions.

1. Open your terminal and go to your Craft project:

### Via Composer (requires access to repo)
cd /path/to/project

Add One Logger to your `composer.json` file:
2. Then tell Composer to load the plugin:

```
{
Expand All @@ -24,36 +38,36 @@ Add One Logger to your `composer.json` file:
],
"require": {
"onedesign/onelogger": "^1.0",
"onedesign/onelogger": "^2.0",
}
}
```
composer update onedesign/onelogger

Then run `composer install` or `composer update` if you already have. Go to the Craft Control Panel to install.
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for onelogger.

You'll probably also want to add the resuling directory, `craft/plugins/onelogger`, to your .gitignore.

### Manually
## Configuration

Alternatively, drop the contents of the plugin into a new `onelogger` directory in `craft/plugins`.
You can configure the log levels that show up in the stderr logs by adding a `onelogger.php` config file (and an ENV var).

The resulting structure would look like this:
`config/onelogger.php`
```
<?php
return [
'logLevels' => getenv('ONELOGGER_LOG_LEVELS') ? explode(',', getenv('ONELOGGER_LOG_LEVELS')) : ['warning', 'error']
];
```

`.env`
```
│craft
|...
├── plugins
| |...
│   ├── onelogger
│   │   ├── LICENSE
│   │   ├── OneLoggerPlugin.php
│   │   ├── README.md
│   │   ├── composer.json
│   │   ├── composer.lock
│   │   ├── loggers
│   │   │   └── OneLogger_StdOut.php
# Set which Craft log levels you want to see in stderr
ONELOGGER_LOG_LEVELS="warning,error,info,trace,profile"
```


## Usage

Log events in Craft as you normally would (eg `Craft::log('Uh oh! Error!', LogLevel::Error)` or `MyPlugin::log(...)`), and you'll see the logs in STDOUT.
Expand All @@ -64,4 +78,5 @@ For example, if you are using Heroku, you can see logs from the command line usi
heroku logs --tail -a app-name
```

You'll continue seeing logs using Craft's normal filesystem logs. (If you're hosting on Heroku, this are ephemeral and will disappear shortly.)
You'll continue seeing logs using Craft's normal filesystem logs. If you're hosting on Heroku, this are ephemeral and will disappear.

50 changes: 37 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
{
"name": "onedesign/onelogger",
"description": "A Craft CMS plugin for logging to STDOUT",
"homepage": "https://github.com/onedesign/onelogger",
"type": "craft-plugin",
"keywords": ["craft","plugin"],
"license": "MIT",
"authors": [{
"name": "One Design Company",
"email": "[email protected]",
"homepage": "https://onedesigncompany.com"
}],
"require": {
"composer/installers": "~1.4"
"name": "onedesign/onelogger",
"description": "Logging Alternative for Craft CMS 3.x using STDOUT and STDERR",
"type": "craft-plugin",
"version": "2.0.0",
"keywords": [
"craft",
"cms",
"craftcms",
"craft-plugin",
"onelogger"
],
"support": {
"docs": "https://github.com/onedesign/onelogger/blob/master/README.md",
"issues": "https://github.com/onedesign/onelogger/issues"
},
"license": "MIT",
"authors": [
{
"name": "One Design Company",
"homepage": "https://onedesigncompany.com"
}
],
"require": {
"craftcms/cms": "^3.0.0-RC1"
},
"autoload": {
"psr-4": {
"onedesign\\onelogger\\": "src/"
}
},
"extra": {
"name": "onelogger",
"handle": "onelogger",
"hasCpSettings": false,
"hasCpSection": false,
"changelogUrl": "https://raw.githubusercontent.com/onedesign/onelogger/master/CHANGELOG.md",
"class": "onedesign\\onelogger\\OneLogger"
}
}
Loading

0 comments on commit 3d42216

Please sign in to comment.