Giter Site home page Giter Site logo

yiisoft / log-target-db Goto Github PK

View Code? Open in Web Editor NEW
14.0 18.0 5.0 155 KB

Yii Logging Library - DB Target

Home Page: https://www.yiiframework.com/

License: BSD 3-Clause "New" or "Revised" License

PHP 98.37% PLSQL 1.63%
yii3 psr-3 db hacktoberfest

log-target-db's Introduction

Yii Logging Library - DB Target


Latest Stable Version Total Downloads codecov Mutation testing badge static analysis type-coverage

This package provides the Database target for the yiisoft/log library.

Supported databases

Packages PHP Versions CI-Actions
[db-mssql] 8.0 - 8.2 2017 - 2022 mssql
[db-mysql/mariadb] 8.0 - 8.2 5.7-8.0/10.4-10.10 mysql
[db-oracle] 8.0 - 8.2 11C - 21C oracle
[db-pgsql] 8.0 - 8.2 9.0 - 15.0 pgsql
[db-sqlite] 8.0 - 8.2 3:latest sqlite

Requirements

  • PHP 8.0 or higher.
  • PDO PHP extension.

Installation

The package could be installed with composer:

composer require yiisoft/log-target-db --prefer-dist

Create database connection

For more information see yiisoft/db.

Database Preparing

Package provides two way for preparing database:

  1. Raw SQL. You can use it with the migration package used in your application.

  2. DbSchemaManager for ensureTable(), ensureNoTable() methods for log table (by default {{%yii_log}}).

// Create db schema manager
$dbSchemaManager = new DbSchemaManager($db);

// Ensure table with default name
$dbSchemaManager->ensureTable();

// Ensure table with custom name
$dbSchemaManager->ensureTable('{{%custom_log_table}}');

// Ensure no table with default name
$dbSchemaManager->ensureNoTable();

// Ensure no table with custom name
$dbSchemaManager->ensureNoTable('{{%custom_log_table}}');

General usage

When creating an instance of \Yiisoft\Log\Logger, you must pass an instance of the database connection.

Creating a target:

$dbTarget = new \Yiisoft\Log\Target\Db\DbTarget($db, $table);
  • $db (\Yiisoft\Db\Connection\ConnectionInterface) - The database connection instance.
  • $table (string) - The name of the database table to store the log messages. Defaults to "log".

Creating a logger:

$logger = new \Yiisoft\Log\Logger([$dbTarget]);

You can use multiple databases to store log messages:

/**
 * @var \Yiisoft\Db\Connection\ConnectionInterface $mysqlDb
 * @var \Yiisoft\Db\Connection\ConnectionInterface $sqliteDb
 */

$logger = new \Yiisoft\Log\Logger([
    new \Yiisoft\Log\Target\Db\DbTarget($mysqlDb),
    new \Yiisoft\Log\Target\Db\DbTarget($sqliteDb),
]);

For a description of using the logger, see the yiisoft/log package.

See Yii guide to logging for more info.

Support

If you need help or have a question, the Yii Forum is a good place for that. You may also check out other Yii Community Resources.

Testing

Check the testing instructions to learn about testing.

Support the project

Open Collective

Follow updates

Official website Twitter Telegram Facebook Slack

License

The Yii Logging Library - DB Target is free software. It is released under the terms of the BSD License. Please see LICENSE for more information.

Maintained by Yii Software.

log-target-db's People

Contributors

darkdef avatar dependabot[bot] avatar devanych avatar fantom409 avatar machour avatar samdark avatar sankaest avatar schmasterz avatar terabytesoftw avatar viktorprogger avatar vjik avatar xepozz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

log-target-db's Issues

Dependabot can't resolve your PHP dependency files

Dependabot can't resolve your PHP dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Installation request for yiisoft/yii-web ^3.0@dev -> satisfiable by yiisoft/yii-web[3.0.x-dev].
    - yiisoft/yii-web 3.0.x-dev requires psr/http-factory-implementation 1.0 -> no matching package found.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
 - It's a private package and you forgot to add a custom repository to find it

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.