@blackglory/logger-js
TypeScript icon, indicating that this package has built-in type declarations

0.13.2 • Public • Published

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 {}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.13.21latest

Version History

VersionDownloads (Last 7 Days)Published
0.13.21
0.13.11
0.13.01
0.12.11
0.12.01
0.11.01
0.10.21
0.10.11
0.10.01
0.9.01
0.8.21
0.8.11
0.8.01
0.7.61
0.7.51
0.7.41
0.7.31
0.7.21
0.7.11
0.7.01
0.6.11
0.6.01
0.5.61
0.5.51
0.5.41
0.5.31
0.5.21
0.5.11
0.5.01
0.4.51
0.4.41
0.4.31
0.4.21
0.4.11
0.4.01
0.3.191
0.3.181
0.3.161
0.3.151
0.3.141
0.3.131
0.3.121
0.3.111
0.3.101
0.3.91
0.3.81
0.3.61
0.3.51
0.3.41
0.3.31
0.3.21
0.3.11
0.3.01
0.2.21
0.2.11
0.2.01
0.1.161
0.1.151
0.1.141
0.1.131
0.1.121
0.1.111
0.1.101
0.1.91
0.1.81
0.1.71
0.1.51
0.1.41
0.1.31
0.1.21
0.1.11
0.1.01

Package Sidebar

Install

npm i @blackglory/logger-js

Weekly Downloads

72

Version

0.13.2

License

MIT

Unpacked Size

31.1 kB

Total Files

15

Last publish

Collaborators

  • black_glory