Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

馃崉 [RFC][LCB stdlib] Add logging syntax #1758

Open
wants to merge 1 commit into
base: develop
Choose a base branch
Loading
from

Conversation

peter-b
Copy link
Contributor

@peter-b peter-b commented Feb 2, 2015

It would be really useful to have a basic logging API in the LCB stdlib. The basic syntax could be something like:

log message "foo"
-- Log at "info" level by default
-- Outputs "(myprogram:pid) Message **: foo"

log warning message "foo"
-- Outputs "(myprogram:pid) WARNING **: foo"

Initial implementation

  • Support for log levels "error", "warning", "message", and "debug" (corresponding roughly to syslog(3) levels LOG_CRIT, LOG_WARNING, LOG_NOTICE and LOG_DEBUG).
  • Log output always goes to stderr with the formatting as above
  • "log error" always quits

Later

Later on we could add additional features, like

  • Support for the default output to be to syslog(3) instead of to stderr, if appropriate
  • More log levels, like "critical" (like an error, but doesn't quit)
  • Ability to turn off debugging log messages
  • String formatting

Practical considerations

This would be initially implemented by in pure LCB by binding to any necessary libfoundation functions and encoding all strings passed to ASCII. It would also frob stderr by using cstdio functions directly. I.e. quick dirty hack.

Nothing yet; watch this space.
@peter-b peter-b added the WIP label Feb 2, 2015
@runrevmark
Copy link
Contributor

This looks good :)

One thing to take into account is that there is already a 'log' syntax in the engine module which Ben et al. have been using. I don't think it conflicts but would be good to think about how we can roll them into one.

@peter-b
Copy link
Contributor Author

peter-b commented Feb 2, 2015

Yes, I'd really like to unify the syntaxes. The problem is that the engine lib's log syntax supports format strings and I'm not quite ready to implement a formatting engine in LCB.

@runrevmark
Copy link
Contributor

Well the engine log command was a 'quick and dirty' thing so Ben et al could debug their code... It should perhaps be ear-marked as temporary :)

Logging should really be the domain of the standard library level I think - as long as the engine can connect up to the output of the lower level logging facilities to display them in the IDE.

@peter-b
Copy link
Contributor Author

peter-b commented Feb 2, 2015

Well, one option would be to provide a way to register a "log dispatcher" function callback with libsystem. I wish it was feasible to do engine bits in pure LCB. 馃槈

@livecodestephen
Copy link
Contributor

For our server code we've got a log handler, which just prefixes each line with a timestamp and an indent. The indent can be incremented or decremented which can be useful to give some indication of where messages come from in the call stack.

@peter-b
Copy link
Contributor Author

peter-b commented Feb 3, 2015

@livecodestephen For server stacks, we really should provide a way to use syslog(3), which will take care of all the PID / timestamp / etc. information, log storage, log rotation, etc.

@runrevmark runrevmark added the LCB label Mar 13, 2015
@peter-b peter-b closed this Apr 13, 2017
@peter-b peter-b deleted the feature-lcblogging branch April 13, 2017 12:01
@peter-b peter-b restored the feature-lcblogging branch April 13, 2017 12:38
@peter-b peter-b reopened this Apr 13, 2017
@peter-b peter-b changed the title [RFC][LCB stdlib] Add logging syntax [DEAD][RFC][LCB stdlib] Add logging syntax Apr 13, 2017
@peter-b peter-b changed the title [DEAD][RFC][LCB stdlib] Add logging syntax 馃崉 [RFC][LCB stdlib] Add logging syntax Apr 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.