On this page

paweljarosz/squid/squid.squid

Squid is a standalone injectable system for saveable logging of user logs, errors and crashes for Defold.

  • GitHub: paweljarosz/squid — pinned to 2fe3aed
    1. Pick a release from paweljarosz/squid releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as squid from "squid.squid"

Functions

new(tag?: string, is_allowed?: boolean): SquidInstance

Create a new instance of the Squid logger

Parameters

  • tag?: string
  • is_allowed?: boolean

Returns

  • SquidInstance

get_config(): SquidConfig

Get Squid configuration

Returns

  • SquidConfig

set_config(config: SquidConfig)

Set and use user configuration

Parameters

  • config: SquidConfig

init()

Initialize Squid for error and crash handling and logging

set_allowed(tag: string, enabled: boolean)

Set if logs should be saved to file

Parameters

  • tag: string
  • enabled: boolean

trace(message: string, data?: AnyNotNil, tag?: string)

Parameters

  • message: string
  • data?: AnyNotNil
  • tag?: string

debug(message: string, data?: AnyNotNil, tag?: string)

Parameters

  • message: string
  • data?: AnyNotNil
  • tag?: string

info(message: string, data?: AnyNotNil, tag?: string)

Parameters

  • message: string
  • data?: AnyNotNil
  • tag?: string

warn(message: string, data?: AnyNotNil, tag?: string)

Parameters

  • message: string
  • data?: AnyNotNil
  • tag?: string

error(message: string, data?: AnyNotNil, tag?: string)

Parameters

  • message: string
  • data?: AnyNotNil
  • tag?: string

log(message: string, level: number, data?: AnyNotNil, tag?: string)

Log message with provided level, message, data and tag

Parameters

  • message: string
  • level: number
  • data?: AnyNotNil
  • tag?: string

save_logs(): boolean

Explicitly save buffer of unsaved logs to file

Returns

  • boolean — true if saved logs successfully, false otherwise

final()

Finalize Squid logging - check for crashes and saved all unsaved buffered logs

Variables

TRACE: number

DEBUG: number

INFO: number

WARN: number

ERROR: number

Types

SquidInstance.init()

Initialize Squid for error and crash handling and logging

SquidInstance.set_allowed(tag: string, enabled: boolean)

Set if logs should be saved to file

Parameters

  • tag: string
  • enabled: boolean

SquidInstance.trace(message: string, data?: AnyNotNil, tag?: string)

Parameters

  • message: string
  • data?: AnyNotNil
  • tag?: string

SquidInstance.debug(message: string, data?: AnyNotNil, tag?: string)

Parameters

  • message: string
  • data?: AnyNotNil
  • tag?: string

SquidInstance.info(message: string, data?: AnyNotNil, tag?: string)

Parameters

  • message: string
  • data?: AnyNotNil
  • tag?: string

SquidInstance.warn(message: string, data?: AnyNotNil, tag?: string)

Parameters

  • message: string
  • data?: AnyNotNil
  • tag?: string

SquidInstance.error(message: string, data?: AnyNotNil, tag?: string)

Parameters

  • message: string
  • data?: AnyNotNil
  • tag?: string

SquidInstance.log(message: string, level: number, data?: AnyNotNil, tag?: string)

Log message with provided level, message, data and tag

Parameters

  • message: string
  • level: number
  • data?: AnyNotNil
  • tag?: string

SquidInstance.save_logs(): boolean

Explicitly save buffer of unsaved logs to file

Returns

  • boolean — true if saved logs successfully, false otherwise

SquidInstance.final()

Finalize Squid logging - check for crashes and saved all unsaved buffered logs

SquidInstance.tag: string