Skip to content

Commit

Permalink
Refactor utils into directory
Browse files Browse the repository at this point in the history
  • Loading branch information
jsumners committed Aug 30, 2023
1 parent a3fefcb commit e55ccd7
Show file tree
Hide file tree
Showing 29 changed files with 1,008 additions and 866 deletions.
8 changes: 8 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": [
"standard"
],
"rules": {
"no-var": "off"
}
}
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const {
prettifyTime,
buildSafeSonicBoom,
filterLog,
handleCustomlevelsOpts,
handleCustomlevelNamesOpts
handleCustomLevelsOpts,
handleCustomLevelsNamesOpts
} = require('./lib/utils')

const jsonParser = input => {
Expand All @@ -40,7 +40,7 @@ const defaultOptions = {
useOnlyCustomProps: true,
levelFirst: false,
messageKey: MESSAGE_KEY,
messageFormat: false,
messageFormat: null,
timestampKey: TIMESTAMP_KEY,
translateTime: true,
useMetadata: false,
Expand All @@ -65,8 +65,8 @@ function prettyFactory (options) {
const errorLikeObjectKeys = opts.errorLikeObjectKeys
const errorProps = opts.errorProps.split(',')
const useOnlyCustomProps = typeof opts.useOnlyCustomProps === 'boolean' ? opts.useOnlyCustomProps : opts.useOnlyCustomProps === 'true'
const customLevels = handleCustomlevelsOpts(opts.customLevels)
const customLevelNames = handleCustomlevelNamesOpts(opts.customLevels)
const customLevels = handleCustomLevelsOpts(opts.customLevels)
const customLevelNames = handleCustomLevelsNamesOpts(opts.customLevels)

const customColors = opts.customColors
? opts.customColors
Expand Down
9 changes: 9 additions & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
'use strict'

/**
* A set of property names that indicate the value represents an error object.
*
* @typedef {string[]} K_ERROR_LIKE_KEYS
*/

module.exports = {
DATE_FORMAT: 'yyyy-mm-dd HH:MM:ss.l o',
DATE_FORMAT_SIMPLE: 'HH:MM:ss.l',

/**
* @type {K_ERROR_LIKE_KEYS}
*/
ERROR_LIKE_KEYS: ['err', 'error'],

MESSAGE_KEY: 'msg',
Expand Down
Loading

0 comments on commit e55ccd7

Please sign in to comment.