0.13.2 • Published 1 year ago

@blackglory/logger-js v0.13.2

Weekly downloads
287
License
MIT
Repository
github
Last release
1 year ago

logger-js

Install

npm install --save @blackglory/logger-js
# or
yarn add @blackglory/logger-js

API

LoggerClient

interface ILoggerClientOptions {
  server: string
  basicAuth?: {
    username: string
    password: string
  }
  keepalive?: boolean
  heartbeat?: IHeartbeatOptions
  timeout?: number
}

interface ILoggerClientRequestOptions {
  signal?: AbortSignal
  keepalive?: boolean
  timeout?: number | false
}

export interface ILoggerClientFollowOptions {
  since?: LogId
  heartbeat?: IHeartbeatOptions
}

interface IHeartbeatOptions {
  timeout: number
}

interface ILoggerConfig extends JSONObject {
  timeToLive: number | null
  limit: number | null
}

type LogId = `${number}-${number}`

interface IRange {
  order: Order
  from?: LogId
  to?: LogId
  skip?: number
  limit?: number
}

enum Order {
  Asc = 'asc'
, Desc = 'desc'
}

interface ILog {
  id: LogId
  value: JSONValue
}

class LoggerNotFound extends CustomError {}

class LoggerClient {
  constructor(options: ILoggerClientOptions)

  getAllLoggerIds(options?: ILoggerClientRequestOptions): Promise<string[]>

  setLogger(
    loggerId: string
  , config: ILoggerConfig
  , options?: ILoggerClientRequestOptions
  ): Promise<void>

  getLogger(
    loggerId: string
  , options?: ILoggerClientRequestOptions
  ): Promise<ILoggerConfig | null>

  removeLogger(
    loggerId: string
  , options?: ILoggerClientRequestOptions
  ): Promise<void>

  log(
    loggerId: string
  , value: JSONValue
  , options?: ILoggerClientRequestOptions
  ): Promise<void>

  /**
   * @throws {LoggerNotFound}
   */
  follow(
    loggerId: string
  , options?: ILoggerClientFollowOptions
  ): AsyncIterableIterator<ILog>

  /**
   * @throws {LoggerNotFound}
   */
  getLogs(
    loggerId: string
  , logIds: LogId[]
  , options?: ILoggerClientRequestOptions
  ): Promise<Array<JSONValue | null>>

  removeLogs(
    loggerId: string
  , logIds: LogId[]
  , options?: ILoggerClientRequestOptions
  ): Promise<void>

  /**
   * @throws {LoggerNotFound}
   */
  queryLogs(
    loggerId: string
  , range: IRange
  , options?: ILoggerClientRequestOptions
  ): Promise<ILog[]>

  clearLogs(
    loggerId: string
  , range: IRange
  , options?: ILoggerClientRequestOptions
  ): Promise<void>
}

class HeartbeatTimeoutError extends CustomError {}
class LoggerNotFound extends CustomError {}
0.13.1

1 year ago

0.13.2

1 year ago

0.13.0

1 year ago

0.12.1

2 years ago

0.11.0

2 years ago

0.10.1

2 years ago

0.12.0

2 years ago

0.10.2

2 years ago

0.10.0

2 years ago

0.9.0

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.8.2

2 years ago

0.7.6

2 years ago

0.7.5

2 years ago

0.7.4

2 years ago

0.7.2

3 years ago

0.7.1

3 years ago

0.7.3

3 years ago

0.7.0

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.6

3 years ago

0.5.5

3 years ago

0.5.4

3 years ago

0.5.3

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.5.0

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.19

4 years ago

0.3.18

4 years ago

0.3.16

4 years ago

0.3.15

4 years ago

0.3.14

4 years ago

0.3.13

4 years ago

0.3.12

4 years ago

0.3.11

4 years ago

0.3.9

4 years ago

0.3.10

4 years ago

0.3.8

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.2.2

4 years ago

0.1.15

4 years ago

0.1.16

4 years ago

0.1.14

4 years ago

0.1.13

4 years ago

0.1.12

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.2

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago