Skip to content

Latest commit

 

History

History
71 lines (55 loc) · 1.56 KB

README.md

File metadata and controls

71 lines (55 loc) · 1.56 KB

AQdonisjs Api Demo

Serve application

Use the bash command to serve application.

npm run serve:dev

Migrations

Run the following command to run startup migrations.

adonis migration:run

Create Controller

Run the following command to create a new controller.

adonis make:controller User --type http

Create Model

Run the following command to create a new model.

adonis make:model Property -m -c

Logger

The configuration for Logger is saved inside the config/app.js file under the logger object:

logger: {
  transport: 'console',
  console: {
    driver: 'console'
  },
  file: {
    driver: 'file',
    filename: 'adonis.log'
  }
}

Let’s start with a basic example of logging data within your app:

const Logger = use('Logger')

Logger.info('request url is %s', request.url())

Logger.info('request details %j', {
  url: request.url(),
  user: auth.user.username()
})

The logger uses RFC5424 log levels, exposing simple methods for each level:

Level Method Usage
0 emerg Logger.emerg(msg, …​data)
1 alert Logger.alert(msg, …​data)
2 crit Logger.crit(msg, …​data)
3 error Logger.error(msg, …​data)
4 warning Logger.warning(msg, …​data)
4 warning Logger.warning(msg, …​data)
6 info Logger.info(msg, …​data)
7 debug Logger.debug(msg, …​data)